I'm blocked on a stupid problem in one of my functions.
I want to get the generatedKey of one of my Sql query. I can't and i don't understand why. The problem is that resultSet.next()
it return false even if the line have been inserted when I check the data in the table.
Here is my code :
Statement statement = connection.createStatement();
statement.executeUpdate("INSERT INTO calamar.calamar.application (nom,criticite,autorise) VALUES ('"+nom+"','"+criticite+"','"+false+"');");
ResultSet resultSet = statement.getGeneratedKeys();
resultSet.next();
Solution : Add Statement.RETURN_GENERATED_KEYS
Statement statement = connection.createStatement();
statement.executeUpdate("INSERT INTO calamar.calamar.application (nom,criticite,autorise) VALUES ('"+nom+"','"+criticite+"','"+false+"');", Statement.RETURN_GENERATED_KEYS);
ResultSet resultSet = statement.getGeneratedKeys();
resultSet.next();