-
1. Re: Generated Key from MySQL
shawkins May 13, 2014 10:07 AM (in response to gadeyne.bram)You are probably hitting [TEIID-2852] Retrieval of AUTO GENERATED Keys does not work with JDBC Translator - JBoss Issue Tracker
Can you provide more of the stacktrace to confirm?
-
2. Re: Generated Key from MySQL
gadeyne.bram May 13, 2014 10:41 AM (in response to shawkins)Oh, no I don't think so. I close the statement in a finally block.
String query = "insert into patient_admission(patientid,admissiontime, dischargetime, bed, ward) values(?,?,?,?,?)";
PreparedStatement pstmt=null;
try{
pstmt=TeiidConnectionManager.getInstance().getStatementWithReturn(query);
pstmt.setX //setters for pstmt
pstmt.executeUpdate(); // At this line the exception is thrown
} catch (SQLException e) {
log.log(Level.SEVERE,"Could not insert patient_admission",e);
return null;
}finally{
if(pstmt!=null){
try {pstmt.close();} catch (SQLException e) {}
}
}
The getStatement method from TeiidConnectionManager looks like this:
public PreparedStatement getStatementWithReturn(String query) throws SQLException{
return getConnection().prepareStatement(query, Statement.RETURN_GENERATED_KEYS);
}
The getConnection method just sets up the the connection.
-
3. Re: Generated Key from MySQL
shawkins May 13, 2014 10:44 AM (in response to gadeyne.bram)The issue affects the translator, not your client code. Can you retry your scenario with 8.7?
-
4. Re: Generated Key from MySQL
gadeyne.bram May 14, 2014 7:24 AM (in response to shawkins)Great! In 8.7 it works!
With kind regards
Bram