Sorry if my question is trivial but I am new to Java programming.
I have a following problem: I created a derby database using NetBeans IDE (I went to Services tab -> JavaDB -> create database). Then I created my java project and added reference to derbyclient.jar. Using these arguments:
String host = "jdbc:derby://localhost:1527/Employees";
String username = "jarek";
String pass = "aaa";
I managed to create jdbc Connection and was able to populate ResultSet with data from table Employees. Next I wanted to update database using this result set so I wrote:
rs.absolute(rowtoupdate);
rs.updateObject("FIRST_NAME", updatedvalue);
rs.updateRow();
and everything worked fine (data was actually updated in database).
Now to my problem. I wanted this database to be embedded in my application so I copied its files into foleder "DB" in my project's location (I copied Employees folder as well as derby.log and derby.properties). I changed referenced in project jar file from derbyclient.jar to derby.jar. After that I used different arguments:
String host = "jdbc:derby:DB//Employees";
String username = "jarek";
String pass = "aaa";
String driver = "org.apache.derby.jdbc.EmbeddedDriver";
Class.forName( driver );
connection = DriverManager.getConnection( url, username, password );
Again I was able to populate resultSet with data from database (so everything seems to work) but when I try to perform exact same update:
rs.absolute(rowtoupdate);
rs.updateObject("FIRST_NAME", updatedvalue);
rs.updateRow();
changes aren't kept in database.
What am I doing wrong? Can it be caused by me copying database files to my project's location? But then again resultSet after running a query on Statement contains proper data from database so it seems to work...
Calling connection.commit() solves the problem.