Index: org/postgresql/jdbc2/AbstractJdbc2Statement.java =================================================================== RCS file: /cvsroot/jdbc/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v retrieving revision 1.114 diff -u -r1.114 AbstractJdbc2Statement.java --- org/postgresql/jdbc2/AbstractJdbc2Statement.java 27 May 2009 23:55:19 -0000 1.114 +++ org/postgresql/jdbc2/AbstractJdbc2Statement.java 6 Aug 2009 13:11:03 -0000 @@ -1229,6 +1229,35 @@ } /* + * Set a parameter to a java.lang.BigInteger value. The driver + * converts this to the narrowest integer representation available + * when it sends it to the database. + * + * This is an extension to the JDBC API! + * + * @param parameterIndex the first parameter is 1... + * @param x the parameter value + * @exception SQLException if a database access error occurs + */ + private void setBigInteger(int parameterIndex, BigInteger x) throws SQLException + { + checkClosed(); + if (x == null) + setNull(parameterIndex, Types.DECIMAL); + else { + int bl = x.bitLength(); + if (bl < 16) + bindLiteral(parameterIndex, x.toString(), Oid.INT2); + else if (bl < 32) + bindLiteral(parameterIndex, x.toString(), Oid.INT4); + else if (bl < 64) + bindLiteral(parameterIndex, x.toString(), Oid.INT8); + else + bindLiteral(parameterIndex, x.toString(), Oid.NUMERIC); + } + } + + /* * Set a parameter to a java.lang.BigDecimal value. The driver * converts this to a SQL NUMERIC value when it sends it to the * database. @@ -1736,6 +1765,8 @@ setString(parameterIndex, (String)x); else if (x instanceof BigDecimal) setBigDecimal(parameterIndex, (BigDecimal)x); + else if (x instanceof BigInteger) + setBigInteger(parameterIndex, (BigInteger)x); else if (x instanceof Short) setShort(parameterIndex, ((Short)x).shortValue()); else if (x instanceof Integer)