Hi
I have an interesting problem. I am using a prepared statement in JBoss 3.0.3 to insert an entry into a table on MS SQL SERVER 7.0.
Connection con = null;
PreparedStatement ps = null;
try {
con = EjbUtils.getConnection();
ps = con.prepareStatement ("INSERT INTO USERINFO (UserInfoId, Logon, UserPassword) VALUES (?,?,?)");
ps.setLong(1, pKey.longValue());
ps.setString(2, logonName);
ps.setString(3, userPassword);
insertResult = ps.executeUpdate();
if (insertResult != 1) {
log.error("Error creating the user the user in the database:
UserInfoId=" + pKey + ", Logon=" + logonName + ",
Password=" + userPassword);
}
}
catch (SQLException e) {
log.error ("Error while creating the user: ",e);
}
finally {
//free the connection
try {
if (ps!=null)
ps.close();
if (con!=null)
con.close();
}
catch (Exception e){
log.error("Exception while freeing db resources", e);
}
}
The ps.executeUpdate() statement returns a result of 1 which I understand to mean that 1 row was modified in the table. When I look at the table however, NO change has been made. The same code on a different table seems to work however. I have confirmed with our IT guys that the table rights are identical between the two tables in question, and if I execute the exact same SQL statement through a GUI interface like TOAD, the statement executes as expected.
I have used an OPTA JDBC driver as well as the 0.9.1 jTDS driver and the results are the same.
ANY suggestions/pointers would be appreciated.
Regards,
Derek.