Win a copy of Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams this week in the Reactive Progamming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Ganesh Patekar

A question about PreparedStatement and ORA-03115 error

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,

 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Google turns up a ton of good info about this error message

ORA-03115: unsupported network datatype or representation
 
dariyoosh za
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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,
 
Those are the largest trousers in the world! Especially when next to this ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!