0
I’m trying to make an INSERT in my bank (Firebird) with Returning to return the registered ID, however, when it arrives at the line stmt.executeUpdate()
i get the Exception Fbsqlexception.
Insert method:
Note 1: I am using netbeans.
public int insereBanco(BancoCTR bancoCTR) {
try {
conn = Conexao.obtemConexao();
String insert = "INSERT INTO BANCO VALUES (null, ?) RETURNING "
+ "BCO_CODIGO";
stmt = conn.prepareStatement(insert);
stmt.setString(1, bancoCTR.getBcoNome());
int i = stmt.executeUpdate();
if (i < 1){
return -1;
}else{
rSet = stmt.executeQuery();
}
if (rSet.next()) {
return rSet.getInt(1);
} else {
return -2;
}
} catch (Exception e) {
System.out.println("Erro ao inserir banco: " + e.getMessage());
return -3;
}
}