Is there some way to check beforehand if a java type is compatible with a sql.Types?
I could type out all the stuff like:
if (BIGINT||TINYINT) try BigInteger.parse(myvalue) and
if (TIME||DATE||TIMESTAMP) try new Date(Long.parse(myvalue))
This creates tonnes of code. Is their some generic way of prechecking?
EDIT: I’m talking about inserts, so I want to do some prechecking, to avoid sql exceptions while inserting
If you’re using JDBC, just use ResultSet.getObject(). It will return what type is appropriate (let the JDBC driver do the heavy lifting).
Only use the typed getters, eg getInt(), when you know what you’re expecting from the column.