Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JDBC and Relational Databases 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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
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
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32635
    
215

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.


[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, 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
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 32635
    
215

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
 
It's not a secret anymore!