Description:
I am developping a web aplication that uses a MySQl database. Recently I updated the 4.1.1 release to a 4.1.2 release of the data base server and I also update the J-connector to the 3.1.2 alpha version.
Unfortunately my application isn't working anymore.
I am using a PreparedStatment to update user information.
sql.append ("UPDATE User_tbl SET User_logName = ?, ").
append ("User_passwd = ?, User_firstName = ?, ").
append ("User_lastName = ?, User_emailAddr = ?, ").
append ("User_role = ?, User_locked = ? WHERE User_ID = ?");
List<Object> values = new ArrayList<Object>(8);
values.add (userInfo.getUser_logName());
values.add (userInfo.getUser_passwd());
values.add (userInfo.getUser_firstName());
values.add (userInfo.getUser_lastName());
values.add (userInfo.getUser_emailAddr());
values.add (new Byte (userInfo.getUser_role()));
values.add (new Boolean (userInfo.getUser_locked()));
values.add (userInfo.getUser_id());
pstmt = conn.prepareStatement (sql.toString());
setValues (pstmt, values);
System.out.println (pstmt);
noOfRows = pstmt.executeUpdate();
When I make a printout of the constructed PS everyting looks fine, but the system throws an exception telling that User_logName is null.
When I execute the same SQL-query using the ControlCenter there is no problem and the user table is updated as should be.
What can be wrong?
P.S. I left out the details for getting the connection and filling in the values in the PS.
How to repeat:
Construct a data base with the following statements
DROP TABLE IF EXISTS user_tbl;
CREATE TABLE `user_tbl` (
`User_ID` int(11) NOT NULL auto_increment,
`User_logName` varchar(10) NOT NULL default '',
`User_passwd` varchar(16) NOT NULL default '',
`User_firstName` varchar(15) NOT NULL default '',
`User_lastName` varchar(25) NOT NULL default '',
`User_emailAddr` varchar(30) default '',
`User_role` tinyint(4) NOT NULL default '0',
`User_locked` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`User_ID`),
UNIQUE KEY `User_logName` (`User_logName`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
INSERT INTO user_tbl
VALUES (0,'admin','password','Administrator','',NULL,0,0);