Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

SQLException: No more data to read from socket

 
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
 
author & internet detective
Posts: 39986
806
Eclipse IDE VI Editor Java
  • 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
Posts: 39986
806
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Odd. Maybe it's a driver bug?
 
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.
 
I do some of my very best work in water. Like this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic