File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes A question about PreparedStatement and ORA-03115 error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "A question about PreparedStatement and ORA-03115 error" Watch "A question about PreparedStatement and ORA-03115 error" New topic
Author

A question about PreparedStatement and ORA-03115 error

dariyoosh za
Greenhorn

Joined: Apr 12, 2009
Posts: 20
Dear all,

I have an issue with JDBC and I would appreciate if you could kindly give me a hand.

I'm using:

- Oracle Database 11g Enterprise (Release 11.1.0.6.0)
- JDBC thin driver version: ( 11.1.0.7.0-Production)
- JDK 1.6
- Operating system: Linux (Ubuntu 8.10)

Here is my code


This works pretty well without any problem. But when I want to use PreparedStatement instead of Statement I receive the ORA-03115 error message, that is, when I replace the Statement with PreparedStatement in the following way:


I get the following:


Therefore, right after

the exception is thrown,

why it works with Statement but not with PreparedStatement? I tested with several other queries, insert a new row, delete a row, everytime it works well, but when I want to use PreparedStatement instead of Statement, again I have this error message.

Any idea?


Thanks in advance,

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Google turns up a ton of good info about this error message

ORA-03115: unsupported network datatype or representation


GenRocket - Experts at Building Test Data
dariyoosh za
Greenhorn

Joined: Apr 12, 2009
Posts: 20
Gregg Bolinger wrote:Google turns up a ton of good info about this error message


Hello there,

Thanks for your reply. I have been googling since yesterday, but I have not found any thread among HOWTOs and several forums (including this one) that explains my problem. That's why I posted here to get some help specifically about my class connection to the database.

Regards,
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15300
    
    6

Well, I don't know if this is the reason or not but you are supplying the query twice.

PreparedStatement prepared_statement = connection.preparedStatement(query_text);
ResultSet query_result = prepared_statement.executeQuery(query_text);

Try just doing

ResultSet query_result = prepared_statement.executeQuery();

Also, on a side note, in java we use camel casing for variable names, not underscores. Your code would follow better conventions if it looked like

ResultSet queryResult = preparedStatement.executeQuery();

dariyoosh za
Greenhorn

Joined: Apr 12, 2009
Posts: 20
Gregg Bolinger wrote:Well, I don't know if this is the reason or not but you are supplying the query twice.

PreparedStatement prepared_statement = connection.preparedStatement(query_text);
ResultSet query_result = prepared_statement.executeQuery(query_text);

Try just doing

ResultSet query_result = prepared_statement.executeQuery();

Also, on a side note, in java we use camel casing for variable names, not underscores. Your code would follow better conventions if it looked like

ResultSet queryResult = preparedStatement.executeQuery();



Hello there,

Thank you very much for your help that solved my problem !!. In fact I had made two mistakes:

First error, I had used '?' also for column names, which is not accepted as the SQL query has to be precompiled, therefore all the columns must be known before the compilation.

Second error (which you pointed out): Instead of writing



I had to write:



I tested with the following



And it works pretty well now!


Thank you very much for your help and for the time you spent for my problem

Kind Regards,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: A question about PreparedStatement and ORA-03115 error