I'm really not familiar with java, but I had this working earlier and now it doesn't.
I have a simple example that uses
| | | Connection conn = DriverManager.getConnection("jdbc:default:connection:"); |
Using javac I need to compile the code with ojdbc7.jar in the class path. No issues.
javac -cp %CLASSPATH%\ojdbc7.jar sql_test.java
When I specify loadjava
loadjava -user SQLAdmin@database -resolve -debug -verbose sql_test.java
arguments: '-user' 'SQLAdmin@database' '-resolve' '-debug' '-verbose' 'sql_test.java'
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/driver/OracleDriver
at oracle.aurora.server.tools.loadjava.DatabaseOptions.connect(DatabaseOptions.java:116)
...
Caused by: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
...
I can put the ojdb7.jar on the loadjava line but I still get the same error message.
Whats odd is that the previous version of the java code is loaded on the server, and while it doesn't work because the database schema has changed, it throws an error that indicates it did bring up a connection correctly.
I've googled everything i can think of to try to figure out the class path of the server, and I have nothing.
sql_test.java below
--------------------------------------
import java.sql.*;
import java.util.*;
import oracle.jdbc.*;
import oracle.jdbc.pool.OracleDataSource;
import oracle.sql.*;
public class sql_test
{
public static String sql_test () throws SQLException
{
String retStr = "ReturnSet: ";
String queryText = "SELECT SYS_GUID() FROM DUAL";
try
{
Connection conn = DriverManager.getConnection("jdbc:default:connection:");
PreparedStatement pstmt = conn.prepareStatement(queryText);
ResultSet rset = pstmt.executeQuery();
ResultSetMetaData meta = rset.getMetaData();
int colCount = meta.getColumnCount();
while (rset.next())
{
for (int i = 1; i <= colCount; ++i)
{
if (i > 1) retStr += ", ";
retStr += meta.getColumnName(i);
retStr += "=";
retStr += rset.getString(i);
}
}
rset.close();
pstmt.close();
}
catch (SQLException e)
{
System.err.println(e.getMessage());
retStr = "Caught SQLException: ";
//retStr += e.getMessage();
retStr += queryText;
}
return retStr;
}
}