Get the primary key generated by a sequence using jdbctemplate / jdbc for Hana db

We are trying to insert a record in hana db, so we are currently using the jdbc template and key holder to save data and get the newly created column identifier. This works well for postgress, but not for hana.

query ="SELECT CURRENT_IDENTITY_VALUE() FROM \"HALOSYS\".\"HaloTestDemo\"";  
resultSet =  stmt.executeQuery(query);

The above statement gives the current value of the identifier, but this does not match our context where we want to use the jdbc template. Please let me know how to fix this. if we add prepared generated keys, I get a follwing exception

com.sap.db.jdbc.exceptions.jdbc40.SQLFeatureNotSupportedException: Method prepareStatement( String, int )() of Connection is not supported.
+4
source share

Source: https://habr.com/ru/post/1661691/


All Articles