How to pass BigInteger from java to Postgres?

I need to pass a BigInteger argument to SQL query. (on Postgres 9.2) I have this code in my DAO:

    public List<PersonInfo> select(String id) {
        BigInteger bigIntId = new BigInteger(id);
        JdbcTemplate select = new JdbcTemplate(dataSource);
        return select
                    new Object[] { bigIntId },
                    new PersonRowMapper());

I am getting the following exception:

{"error":"Error invoking getPersonInfoById.[org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; 
nested exception is org.postgresql.util.PSQLException: 
Can't infer the SQL type to use for an instance of java.math.BigInteger. 
Use setObject() with an explicit Types value to specify the type to use.]"}

The id is of type bigint

Tried to pass plain String - also throws type exception. Googled the message in the exception - no relevant result. Any ideas?


The JDBC specification does not include support for BigInteger; you either need to use a different datatype (eg BigDecimal with scale 0), or find out if the PostgreSQL driver offers some implementation specific way to set a BigInteger value.

Need Your Help

PMD working inside intellij as an External Tool

intellij-idea pmd

I would like to make it so that I can Run a PMD check as an external tool from withing intellij 14.x

JQuery Draggable to Drag to Position Programmatically

javascript jquery jquery-ui jquery-ui-draggable

I want to add buttons somewhere on the page to manipulate JQuery Draggable element without mouse dragging, i.e. programmatically. In other words, I want to shift (or pan) draggable element inside its

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.