Question

I have data in a mySQL database table. I am selecting this data and trying to insert it to a Netezza database table. I am using the spring framework and have a entity class called Student.

Some of the fields in the mySQL database table are in Integer format but the equivalent field in Netezza is in character format.

I am using a JDBC template and getting the data from mySQL and inserting that Student object to Netezza.

Here is my method:

 String sqlStudent="INSERT INTO STUDENT(STUDENTID,CLASSID,COURSEID,TESTDATE,SCOREDATE) VALUES (?,?,?,?,?)";
 netezzaJDBCTemplate.update(sqlStudent,new Object[] {student.getStudentId(),student.getClassId(),student.getCourseId(),student.getTestDate(),student.getScoreDate)});

I get an error when I do this. I even tried hard coding the INSERT.

 Exception in thread "main" org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [INSERT INTO STUDENT(STUDENTID,CLASSID,COURSEID,TESTDATE,SCOREDATE) VALUES (1521995,134,21,'2014-02-15 00:00:00','2014-02-15 00:00:00') )]; nested exception is org.netezza.error.NzSQLException: Parameter Index out of range: 1    

Is this because of the difference in the column data types between the 2 databases? or am I missing something else?

Please help.

Was it helpful?

Solution

new studentMapper() might be the issue. JdbcTemplate's update method wont accept RowMapper correct?

If your are not using NamedParameterJdbcTemplate try to prefer that over regular JdbcTemplate which lets you bind the sql params with names.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top