I was trying to retrieve sequence id after immediate insert the record. I am getting java.sql.SQLException: Unsupported feature
. I search and found that the issue is ojdbc14.jar
is not supporting this Statement.RETURN_GENERATED_KEYS
or PreparedStatement.RETURN_GENERATED_KEYS
. so i replaced with ojdbc6.jar
file . But still facing the same issue. Is there any workaround for this issue. Am posting the jdbc code also.
conn = DbUtils.getConnection();
String sql = "insert into abcimages (ACCOUNT_ID, LANGUAGE_CODE, CNTR_ID, IG_CAT_ID, CP_ID, MY_GRP_ID," +
"FILE_TYPE_CODE, IG_NAME, IG_DESCR, START_VALID_DATE, END_VALID_DATE, IG_BIN) values (?,?,?,?,?,?,?,?,?,?,?,?)" ;
// PreparedStatement pstmt = conn.prepareStatement(sql, PreparedStatement.RETURN_GENERATED_KEYS);
PreparedStatement pstmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
pstmt.setLong(1, 1234);
pstmt.setString(2, "ENG");
pstmt.setLong(3, new Long(addDetails.getCntr_id()));
pstmt.setLong(4, new Long(addDetails.getImage_cat_id()));
pstmt.setLong(5, new Long(addDetails.getCpn_id()));
pstmt.setString(6, null);
pstmt.setString(7, "JPG");
pstmt.setString(8, addDetails.getImage_name());
pstmt.setString(9, addDetails.getImage_descr());
pstmt.setDate(10, sqlStartDate);
pstmt.setDate(11, sqlendDate);
pstmt.setNull(12, java.sql.Types.BLOB);
pstmt.executeUpdate();
if (pstmt.executeUpdate() > 0) {
java.sql.ResultSet generatedKeys = pstmt.getGeneratedKeys();
if (generatedKeys.next())
key = generatedKeys.getInt(1);
}
// updateImage(imgfile, conn);
pstmt.close();
conn.close();
}catch (DbConnectionException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return "Oops ! Something Went Wrong. Please Check CWC_PROD_LOG_OUT.";
}finally{
DbUtils.closeConnection(conn);
}
return "Successfully Updated !!!";
Any help on this much appreciated.