Search Results

Search found 1 results on 1 pages for 'user1103504'.

Page 1/1 | 1 

  • How to convert a list object to bigdecimal in prepared statement?

    - by user1103504
    I am using prepared statement for bulk insertion of records. Iam iterating a list which contains values and their dataTypes differ. One of the data type is BigDecimal and when i try to set calling preparedstatement, it is throwing null pointer exception. My code int count = 1; for (int j = 0; j < list.size(); j++) { if(list.get(j) instanceof Timestamp) { ps.setTimestamp(count, (Timestamp) list.get(j)); } else if(list.get(j) instanceof java.lang.Character) { ps.setString(count, String.valueOf(list.get(j))); } else if(list.get(j) instanceof java.math.BigDecimal) { ps.setBigDecimal(count, (java.math.BigDecimal)list.get(j)); } else { ps.setObject(count, list.get(j)); } count++; } I tried 2 ways to convert, casting the object and tried to create a new object of type BigDecimal ps.setBigDecimal(count, new BigDecimal(list.get(j).toString)); both donot solve my problem. It is throwing null pointer exception. help is appreciated. Thanks

    Read the article

1