hi, thank u for wrapper sqlite jdbc on android, that r lot help, we can direct convert from web project. except one, on the document, PreparedStatement.executeUpdate return is:
the number of affected rows for INSERT, UPDATE or DELETE statements, 0 for statements that return nothing.
but sqldroid not, return 1 even no rows hit, test code here:
try {
DriverManager.registerDriver((Driver) Class.forName("org.sqldroid.SQLDroidDriver").newInstance());
final String jdbcUrl = "jdbc:sqldroid:/storage/sdcard1/test.sqlite3";
final Connection c = DriverManager.getConnection(jdbcUrl);
final PreparedStatement pst = c.prepareStatement(
"update aw3config set ckey=?, cvalue=? where ckey=?"
);
pst.setObject(1, "a");
pst.setObject(2, "a");
pst.setObject(3, "not_exist");
final int i = pst.executeUpdate();
Log.i("V1", "" + i); //is 1, bug?
final Statement sm = c.createStatement();
final ResultSet rs= sm.executeQuery("select * from aw3config");
Log.i("V2", "" + rs.next()); //false
c.close();
}catch (final Exception e) {
e.printStackTrace();
}
hi, thank u for wrapper sqlite jdbc on android, that r lot help, we can direct convert from web project. except one, on the document, PreparedStatement.executeUpdate return is:
the number of affected rows for INSERT, UPDATE or DELETE statements, 0 for statements that return nothing.
but sqldroid not, return 1 even no rows hit, test code here:
try {
DriverManager.registerDriver((Driver) Class.forName("org.sqldroid.SQLDroidDriver").newInstance());
final String jdbcUrl = "jdbc:sqldroid:/storage/sdcard1/test.sqlite3";
final Connection c = DriverManager.getConnection(jdbcUrl);
final PreparedStatement pst = c.prepareStatement(
"update aw3config set ckey=?, cvalue=? where ckey=?"
);
pst.setObject(1, "a");
pst.setObject(2, "a");
pst.setObject(3, "not_exist");
final int i = pst.executeUpdate();
Log.i("V1", "" + i); //is 1, bug?
final Statement sm = c.createStatement();
final ResultSet rs= sm.executeQuery("select * from aw3config");
Log.i("V2", "" + rs.next()); //false
c.close();
}catch (final Exception e) {
e.printStackTrace();
}