I'm very new to this whole "using both Java and SQL at once" thing and I cannot seem to find a solution for this one. I created a database on a server through Workbench and now I'm creating a simple app in Netbeans which uses it. I tried to create PreparedStatement that would alter my database but just figured out that any changes only last for as long as I keep my application running.. so here's how I did it:
PreparedStatement change2 = connect.prepareStatement("UPDATE database.table1 (column1) VALUES(?) WHERE ID = ?");
change2.setInt(1, int2);
change2.setInt(2, int3);
change2.executeUpdate();
Sorry for how I named everything but I'm doing it in my own language and I wanted to change it so it would be easier to spot any mistakes + names aren't really that relevant here cause I know it works I just want it to be permanent..
So is this a bug or something or did I just forget something to make it last? Thanks for any help in advance :)
Please look at an example here: http://docs.oracle.com/javase/tutorial/jdbc/basics/prepared.html.
If you have set "AutoCommit" to false ie "con.setAutoCommit(false);" as in the above link, the changes are will not be committed to the database. You will have to explicitly call "con.commit();" as done in the example.