Skip to content

Instantly share code, notes, and snippets.

@saswata-dutta
Created April 14, 2020 16:19
Show Gist options
  • Save saswata-dutta/e032dc3632f2ac9524f386776d163c0e to your computer and use it in GitHub Desktop.
Save saswata-dutta/e032dc3632f2ac9524f386776d163c0e to your computer and use it in GitHub Desktop.
Statement stmt = conn.createStatement(
ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
String sql = "SELECT id, name, age FROM students";
ResultSet rs = stmt.executeQuery(sql);
// update data in Result Set
rs.moveToInsertRow();
rs.updateInt("id",5);
rs.updateString("name","John");
rs.updateInt("age",21);
// insert row into database
rs.insertRow();
///////////////////
// no return procedure
{call procedureName(?,?,...)}
// procedure returns result
{? = call procedureName(?,?,...)}
CallableStatement cstmt = null;
try {
String SQL = "{call getExampleName (?, ?)}";
cstmt = conn.prepareCall (SQL);
//. . .
}
catch (SQLException e) {
//. . .
}
finally {
cstmt.close();
}
/////////////////
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment