iam having really an annoying problem .. iam inserting some to DB ( Mysql ) throught ( jdbc ) from ( servlets ) and want to get the last insert id to move on .. but just it doesnt work .. always throws NULL in the exception ..
this is main code for initiating the DB :
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); connection = DriverManager.getConnection( connectionURL, username, password); statement = connection.createStatement();
then i insert some :
database.statement.executeUpdate("insert some into watever");
database.statement.executeQuery("select LAST_INSERT_ID()"); // then i try to print database.rs.getInt(1);
I don't know .. it seems like something is wrong
I tried to remove the part ( database.statement or database.rs ) as iam using my own handler .. and tried to use basic and traditional way " Statemenet st ... and ResultSet rs = ... " for both the insertion query and last_insert_id query .. but still the same ..
please any help .. i wanna move on in my program and iam stuck here days ago