Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SQLException: No more data to read from socket

 
Ankit Doshi
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Ankit Doshi
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry, I forgot to mention that.

I used the OracleDriver and the columns were varchar2.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Odd. Maybe it's a driver bug?
 
teemrap hgnis
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic