Created
February 10, 2014 17:11
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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