Reputation: 11
I'm trying to do an update on a table to a specific row by filtering by id and no long as i try running the query from Java is not saved in the database document.
If I run the query, there's no exceptions and it runs as if it had run successfully, if I do a SELECT to collect the information from Java and see if it has been updated I find that it has been updated correctly, but then if I open the database with MS Access it has not been changed and if I rerun the Java program the changes are not made.
Database class
public class NHRPGDatabase {
static Connection connection;
public Connection openConnection() throws SQLException {
String url = "jdbc:ucanaccess://NHRPGBD.accdb";
return DriverManager.getConnection(url);
}
public void closeConnection(Connection connection) throws SQLException {
connection.close();
}}
Query code
public boolean updateName(int id, String name) throws SQLException {
Connection con = db.openConnection();
con.setAutoCommit(true);
PreparedStatement update = con.prepareStatement("UPDATE Mi_Cuenta SET HabboNombre=? WHERE Id=?");
update.setString(1, name);
update.setInt(2, id);
int result = update.executeUpdate();
db.closeConnection(con);
if (result == 1) {
return true;
} else {
return false;
}
}
Edit: Still don't know why is not working, if i make a update in a fresh made MS Access database it actually works. Seems like the database i'm trying to make the update on its db file version is V2010 [VERSION_14] and the one i've created is 2007 VER 12, i don't know if that helps in any way.
Upvotes: 0
Views: 243
Reputation: 11
Ok, i'm going to answer myself, i discover why is not working, in my MS Access table (where i'm trying to make the update), i have a image row (Ole object) where i have images (bitmap images), i deleted the bitmap images and now it works.
Upvotes: 1