Skip to content

Instantly share code, notes, and snippets.

@arturotena
Created February 10, 2014 17:11
Show Gist options
  • Save arturotena/8920125 to your computer and use it in GitHub Desktop.
Save arturotena/8920125 to your computer and use it in GitHub Desktop.
To update a blob field, either byte or text / Para actualizar un campo tipo blob, ya sea de bytes o de texto
// Para actualizar un campo tipo blob, ya sea de bytes o de texto / To update a blob field, either byte or text
Class.forName(driver);
Connection con = DriverManager.getConnection(...)
Statement stmt = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
String query = "SELECT info FROM tabla WHERE id = 1";
ResultSet rs = stmt.executeQuery(query);
rs.next();
if (esBinario) {
rs.updateBytes(campo, contenidoBytes);
} else { // es texto
rs.updateString(campo, contenidoString);
}
rs.updateRow();
// cerrar / close ResultSet, Statement y Connection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment