You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by Daniel John Debrunner <dj...@debrunners.com> on 2004/11/18 20:50:30 UTC

SQLException messages for null/invalid parameters. (Derby 33)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The JDBC API Tutorial and Reference book says that drivers should throw
SQLExceptions rather than IllegalArgumentExceptions,
NullPointerExceptions etc. [Appendix A.4 in the second version of book].

Derby handles this for passing null to various JDBC methods, such as a
null String reference being passed into Connection.prepareStatement().
The issue is that each method handles this with a unique error message,
I found these four messages at least.

XJ011.S=Cannot pass null for savepoint name.
XJ018.S=Column name cannot be null.
XJ067.S=SQL text pointer is null.
XJ072.S=Null pattern or searchStr passed in to a Blob or Clob position
method.

I wondering if it would be better to have a single message and
consistent way of handling invalid parameters. E.g.

template for message

Invalid value '{0}' passed as parameter '{1}' to method {2}.

Example output

Invalid value 'null' passed as parameter 'sql' to
java.sql.Connection.prepareStatement.

I'm thinking about this in relation to the fix for Derby-33, supporting
an empty Map object for setTypeMap. The correct fix would be handle a
null reference as invalid, empty map as no-op, and anything else as not
implemented. Adding a yet another message seems a little overkill.

Any thoughts?
Dan.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFBnP0GIv0S4qsbfuQRAuzCAJ93YhyXtwCHCdhDMbsq88Armfd0IQCgg8Bn
7Rhq33Bpb5u9eZFKamszMkc=
=7JiC
-----END PGP SIGNATURE-----