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.
The strength of the Wolf is the pack & the strength of the pack is the wolf....Rudyard Kipling
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.
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