• 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 ...
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
  • salvin francis
  • Carey Brown
  • Frits Walraven

PreparedStatement's Error Reporting

Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
  • 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,
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • 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.
Posts: 22
  • Mark post as helpful
  • send pies
  • 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.
Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
Java file APIs (DOC, XLS, PDF, and many more)
    Bookmark Topic Watch Topic
  • New Topic