I am facing difficulty in inserting " last_insert_id" in my prepared statement.I got how to select the last_insert_id in prepared statement like below:
PreparedStatement getLastInsertId = con.prepareStatement("SELECT LAST_INSERT_ID()"); When I use the same procedure for inserting last_insert_id in my preparedstatement like this:
1. PreparedStatement pst = con.prepareStatement("insert into introducer_table values(?,?,?,?)"); 2. 3. //introducer details into database 4. pst.setString(1,LAST_INSERT_ID()); 5. pst.setString(2, nameofintroducer); 6. pst.setString(3, accountno); 7. pst.setString(4, signofintroducer); Im getting 'null' value in the first column.can any one help me to come out from this problem
sidshould not be anullablecolumn since you are telling that it's allowingnull. Or I read something wrong ?