Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/11/2008, 17:40
jesuscoro
 
Fecha de Ingreso: noviembre-2008
Mensajes: 115
Antigüedad: 15 años, 6 meses
Puntos: 4
Problema actualizando campos blob

Hola a todos.

Tengo una base de datos MySql con un campo varchar que guarda una ruta de una imagen. Queria agregar un campo blob que guardara la imagen en si, por lo que agregue el campo y trataba de actualizarlo desde java, pero me da un error diciendo que el resultset no es actualizable, pero si lo es, por que probe a borrar una fila y lo hace. Ya lei el api que me dice el error, pero no encontre nada que me ayude. Decir que el campo fotoAutor ahora mismo es null en todas las filas. Os dejo el codigo que uso y el error que me da a ver si encontramos que es lo que esta mal

Muchas gracias por adelantado

public void blob(){
InputStream inputImage = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance ();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/biblioteca", "root", "josue");
Statement sentencia = con.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
String sql = "SELECT * FROM autor";
ResultSet rs = sentencia.executeQuery(sql);
// rs.last();
// rs.deleteRow();
while(rs.next()){
File file = new File(rs.getString("rutaFotoAutor"));
inputImage = new FileInputStream(file);
rs.updateBlob("fotoAutor", inputImage);
rs.updateRow();
}
} catch (InstantiationException ex) {
Logger.getLogger(OperacionesPersonalizadas.class.g etName()).log(Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
Logger.getLogger(OperacionesPersonalizadas.class.g etName()).log(Level.SEVERE, null, ex);
} catch (ClassNotFoundException ex) {
Logger.getLogger(OperacionesPersonalizadas.class.g etName()).log(Level.SEVERE, null, ex);
} catch (FileNotFoundException ex) {
Logger.getLogger(OperacionesPersonalizadas.class.g etName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(OperacionesPersonalizadas.class.g etName()).log(Level.SEVERE, null, ex);
} finally {
try {
inputImage.close();
} catch (IOException ex) {
Logger.getLogger(OperacionesPersonalizadas.class.g etName()).log(Level.SEVERE, null, ex);
}
}
}

com.mysql.jdbc.NotUpdatable: Result Set not updatable.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, can not use functions and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.This result set must come from a statement that was created with a result set type of ResultSet.CONCUR_UPDATABLE, the query must select only one table, can not use functions and must select all primary keys from that table. See the JDBC 2.1 API Specification, section 5.6 for more details.