Announcement Announcement Module
Collapse
No announcement yet.
SimpleJdbcInsert executeBatch Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleJdbcInsert executeBatch

    Hi I am using the following cod eto do a batch insert but it gives me the following error:

    org.springframework.jdbc.UncategorizedSQLException : PreparedStatementCallback; uncategorized SQLException for SQL [INSERT INTO CLOSINGPRICES (CLOSEDATE, PRODUCTID, REGION, SECURITYTYPE, EXCHANGE, CLOSINGPRICE, TIMESTAMP, HOST_INSTANCE_IDENTIFIER) VALUES(?, ?, ?, ?, ?, ?, ?, ?)]; SQL state [null]; error code [-99999]; Invalid data conversion: Parameter object type is invalid for requested conversion.; nested exception is com.ibm.db2.jcc.b.SqlException: Invalid data conversion: Parameter object type is invalid for requested conversion.

    This works if I insert the records individually! Can you please help

    Code:
    		SqlParameterSource[] array = new SqlParameterSource[productDataObjects.size()]; 
    		
    		for (int i = 0; i < productDataObjects.size(); i++) {
    			
    			ProductDataObject productDataObject = (ProductDataObject)productDataObjects.get(i);
    						
    			array[i] = new MapSqlParameterSource()		
    				.addValue("CLOSEDATE", now, Types.DATE)
    				.addValue("PRODUCTID", productDataObject.getProductIdentifier(), Types.VARCHAR)
    				.addValue("REGION", productDataObject.getRegion(), Types.VARCHAR)
    				.addValue("SECURITYTYPE", productDataObject.getProductType(), Types.VARCHAR)
    				.addValue("EXCHANGE", productDataObject.getExchange(), Types.VARCHAR)
    				.addValue("CLOSINGPRICE", productDataObject.getClosingPrice(), Types.DOUBLE)
    				.addValue("TIMESTAMP", new java.sql.Timestamp(now.getTime()) , Types.TIMESTAMP)
    				.addValue("HOST_INSTANCE_IDENTIFIER", hostname , Types.VARCHAR);
    			
    		}
    
    		insertActor.executeBatch(array);

  • #2
    Can you post the data types that are defined for the actual table colums so we can match that up with the data inserted.

    Comment


    • #3
      Sure..
      Date, Varchar,Varchar,Varchar,Varchar,, Decimal, Timestamp, Varchar

      Comment


      • #4
        I have used batch insert with all of those datatypes. What version of DB2 and JDBC driver are you using?

        Can you post your SimpleJdbcInsert configuration and also the non-batch code you used successfully.

        Also, enabling debug for "org.springframework.jdbc.core" would help tracking this down.

        Comment

        Working...
        X