If you are talking about an integer or long value in a String, then you should be able to just use setString(idx, yourValue)
, setObject(idx, yourValue)
, or setObject(idx, yourValue, java.sql.Types.BIGINT)
the driver should convert this to the target type.
If you are talking about a java.math.BigInteger
, then a JDBC 4.1 (or higher) compliant driver should allow you to set a BigInteger
value to a BIGINT
, CHAR
, VARCHAR
or LONGVARCHAR
column using setObject(idx, yourBigInteger)
, or setObject(idx, yourBigInteger, targetType)
where targetType
is for example java.sql.Types.BIGINT
or java.sql.Types.VARCHAR
.
However, be aware that not all drivers implement this support.
See JDBC 4.1 specification section 3.1 Overview of changes, table B-4 Mapping from Java Object Types to JDBC Types, table B-5 Conversions Performed by setObject
and setNull
Between Java Object Types and Target JDBC Types. Or alternatively, JDBC 4.2 specification, but then only tables B-4 and B-5.