Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

jdbc and statement.executeQuery() throws, statement.execute() doesn

  Asked By: Daryl    Date: May 06    Category: Java    Views: 1353
  

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 with an Oracle internal error - 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.

Share: 

 

No Answers Found. Be the First, To Post Answer.

 




Tagged: