I have a bean that connect to my access database, and an jsp file that uses that bean. if I uses the code on the jsp file without the bean, it would connect to the database and update the database without problem. If I use the bean, with the same code, it will give me any error say: "javax.servlet.ServletException: [Microsoft][ODBC Microsoft Access Driver] The INSERT INTO statement contains the following unknown field name: ''username''. Make sure you have typed the name correctly, and try the operation again. " The operation is try to update a user database after the user registration is successfull.
here is the codes: the code which works in jsp: User newuser = new User("dave", "test", "email@example.com"); PreparedStatement addRecord; Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc dbc:user","",""); addRecord = con.prepareStatement("INSERT INTO User (username, password, email)VALUES( ?, ?, ? )"); //stat.executeUpdate("INSERT INTO ForumUser (username, password, email)VALUES('dave', 'test', 'firstname.lastname@example.org')"); addRecord.setString( 1, newuser.getUsername() ); addRecord.setString( 2, newuser.getPassword() ); addRecord.setString( 3, newuser.getEmail() ); addRecord.executeUpdate(); The above code would insert the user into the database with no problem. but gives me trouble if it is in a bean. Any insight would be appreciated.