PreparedStatement is not working

0

Code I'm using

PreparedStatement i = conexao.prepareStatement("INSERT INTO teste VALUES (player='teste', level_1=0, level_2=0, level_3=0, level_4=0, level_5=0, level_6=0, level_7=0, level_8=0, level_9=0, level_10=0)");
i.executeUpdate();

Table structure.

Just this happens with Insert into , I already used this same code to create the table and it did not give a problem, it just does not insert, what's the problem?

No error, nothing, just does not insert.

    
asked by anonymous 13.06.2015 / 19:17

2 answers

8

By the comments it was possible to find out that the problem was not your code but the database configuration, autocommit was off (so no exception was thrown), so write statements (INSERT, UPDATE, DELETE) are only applied to the database after the call a commit to success or rollback to failure, without calling any of these two commands the query is in a 'draft' state only whoever performed the operation sees the result.

Recommended reading:

Enabling autocommit through workbench or phpmyadmin

What are the advantages and disadvantages of using explicit transaction

MySQL Transaction When? As? Why?

What is a MySQL Transaction for?

    
13.06.2015 / 20:21
0

Try to do this:

PreparedStatement i = conexao.prepareStatement("INSERT INTO teste (player, level_1, level_2, level_3, level_4, level_5, level_6, level_7, level_8, level_9, level_10) VALUES ('teste', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)");
i.executeUpdate();
    
13.06.2015 / 19:26