Tuesday, 20 August 2013

Updating with jdbc, not working and not getting error

Updating with jdbc, not working and not getting error

I'm using jdbc and I'm trying to update some values. I've been all
afternoon with this and finally I don't get any error, but it's not
updating anyway.
Here are the sentences I'm using:
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:java_server.db");
Statement ps2 = null;
conn.setAutoCommit(false);
ResultSet rs = ps.executeQuery();
get_Data();
String and_id = "c0900456e0de0bcc";
String updateString1;
updateString1 = "update device set datess = '" +dateNow+ "'
where android_id='" +and_id+"' ";
ps2 = conn.createStatement();
ps2.executeUpdate(updateString1);
I used this piece of code to insert those values:
PreparedStatement ps = null;
ps = conn.prepareStatement("insert into device values(?,?,?)");
ps.setString(1, splitStr[0]); //ID
ps.setString(2, splitStr[1]); //IP
ps.setString(3, dateNow); // Date
ps.addBatch();
ps.executeBatch();
conn.commit();
Method get_Data returns dateNow as a String with this format: dd/MM/yyyy
HH:mm:ss
What I'm trying to accomplish is to update IP and Date columns from the
and_id selected.

No comments:

Post a Comment