1 last java JDBC question?
I have the following java query
try
{
con = DatabaseUtils.connect(DRIVER, URL);
String sql = "INSERT INTO tblResults (Competitor_ID, Round_ID, result) " +
"SELECT c.ID, r.ID, ? " +
"FROM tblCompetitor AS c, tblRound AS r " +
"WHERE c.Last_Name = ? and r.Round_Number = ?";
ps = con.prepareStatement(sql);
for(int i = 0; i < update2.length; i++)
{
ps.setString(1, update2[i].getTime());
ps.setString(2, update2[i].getLastname());
ps.setString(3, roundType2);
ps.addBatch();
}
int[] upCounts = ps.executeBatch();
con.commit();
}
my array update2 holds 9 objects. The results table is being updated but somtimes it is only doing 8 rows, somtimes 6 etc and also the result column will print out the wrong values, and only ever three of the same values. e.g. if i put values as 1, 2, 3, 4, 5, 6, 7, 8, 9 it prints out 1, 2, 3, 2, 3, 2, 2, 3, 2
I am being returned the stacktrace
sun.jdbc.odbc.JdbcOdbcBatchUpdateException: General error
sun.jdbc.odbc.JdbcOdbcBatchUpdateException: General error
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.emulateExe cuteBatch(JdbcOdbcPreparedStatement.java:2165)
at sun.jdbc.odbc.JdbcOdbcPreparedStatement.executeBat chUpdate(JdbcOdbcPreparedStatement.java:1783)
Does anything look out of place in my code?
? can be used as the sql is done through java and ? is for a prepared statement.
|