I am connecting to an oracle database via JDBC and Java like this:
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connection = DriverManager.getConnection(
"jdbc:oracle:thin:@yadayada", username, password);
Statement statement = connection.createStatement();
If I execute a statement that doesn't return anything such as this:
statement.execute("grant connect to username");
it works fine. On the other hand, when I try something that should
return a ResultSet:
String query = "SELECT * FROM DBA_USERS";
System.out.println(query);
ResultSet rs = statement.executeQuery(query);
the executeQuery() line throws - and yes, the DBA_USERS table exists
in the database ;-)
In fact, if I run the same query - as printed out on the command line
from the System.out.println() - in sqlplus, it returns what I would
expect.
Any help here would be most helpful - as most help usually is :-)
PS there may be some minor type-os as I had to type this in by hand -
don't have a machine at work that connects to the internet.