I'm trying to do an INSERT on my bank (FireBird) with Returning to return the registered ID, however, when it arrives at the stmt.executeUpdate()
line I get the FBSqlException exception.
Insert method:
Note 1: I'm 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;
}
}