• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

PreparedStatement's Error Reporting

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have a PreparedStatement object with a proper query and data set to it.
But when I fire the query(executeUpdate()) it throws as SQLException saying Column length too small for Value.
How Do i know the particular field for which this error was flagged?
Does the SQLException or PreparedStatement object
give me any such sort of information??
Thanks in advance,
Chinmay.
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't even say what database you are using. Or what the text of the PreparedStatement is. Or what JDBC driver you are using, version of JDK, etc. All of this could matter.
However, in general, no you will not be able to tell what column, not from the error message that comes out of the PreparedStatement. Check the lengths of your strings against the declared lengths of the columns in the database. Trying to put 'ABCDE' into a column that is declared CHAR(4), and will give this error. Check the precision and scale of the numbers against the definitions in the database. Trying to put 100.0 or 0.33 into a column declared as NUMBER(2,1) will not work either.
 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The JDBC drivers for most databases (Oracle, DB2, SQLServer, etc) are notoriously horrible at giving error messages. You're usually much better off (if you can) to look in the server logs. If you're using type 2 drivers (like the oracle OCI or DB2Connect), you can also turn up the client side logging and get more info. If you can't get to the logs, poke and hope, like Michael said.
HTH,
Chris
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic