wood burning stoves 2.0*
The moose likes JDBC and the fly likes SQLException: No more data to read from socket Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQLException: No more data to read from socket" Watch "SQLException: No more data to read from socket" New topic
Author

SQLException: No more data to read from socket

Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222
Hi,

I came across this error and spent a few hours before I could get rid of it, hence thought of posting it here in case it may be useful to others.

While trying to run the below update statement from my Java code, I was getting the SQLException: No more data to read from socket from the executeUpdate method call.



When I removed the single quotes from the query (like below), it worked.


By the way, anyone knows the reason why it doesn't work WITH single quotes?

-Ankit
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30076
    
149

Originally posted by Ankit Doshi:
By the way, anyone knows the reason why it doesn't work WITH single quotes?

That would depend on your database driver and whether the columns were char/varchar or numeric.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Ankit Doshi
Ranch Hand

Joined: Dec 04, 2002
Posts: 222
I'm sorry, I forgot to mention that.

I used the OracleDriver and the columns were varchar2.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30076
    
149

Odd. Maybe it's a driver bug?
teemrap hgnis
Greenhorn

Joined: Apr 26, 2009
Posts: 2
this is because you populate the prepared statement params using the data type call
.setString(...) or .setInteger(...) etc therefore you dont need to put the quotes.
When you get a PreparedStatement from connection the passed query is compiled and stored into Oracle so every time its just the params that are populated using the setters.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SQLException: No more data to read from socket
 
Similar Threads
db2 - 703 certification
DB2 700 and 701 - Test Sample
handling quotes in sql queries
Update with FROM table concept
Update Database