0

i am trying to compile this procedure using Dbeaver editor for H2 databse but it doesnt compile and give errors

script is

Create Alias InsertDepartment AS $$ 
 int InsertDepartment(Connection conn,String p_eName,String p_aName ,int p_sec_id) throws Exception {

 String IdQuery="SELECT max (id)+1 FROM DEPARTMENTS";
 java.sql.ResultSet rs = conn.createStatement().executeQuery(IdQuery);
 int id =rs.getInt(1);

 String query=" INSERT INTO DEPARTMENTS (ID,E_NAME,A_NAME,SEC_ID) values ("+id+","+p_eName+","+p_aName+","+p_sec_id+")";
 rs = conn.createStatement().executeQuery(query);
   int resultInt= rs.getInt(1);
   return resultInt;
}
$$;

and the error i get is

DBCException: SQL Error [50000] [HY000]: General error: "java.lang.UnsupportedClassVersionError: org/h2/dynamic/INSERTDEPARTMENT : Unsupported major.minor version 52.0"; SQL statement:
Create Alias InsertDepartment AS $$ 
 int InsertDepartment(Connection conn,String p_eName,String p_aName ,int p_sec_id) throws Exception {

 String IdQuery="SELECT max (id)+1 FROM DEPARTMENTS";
 java.sql.ResultSet rs = conn.createStatement().executeQuery(IdQuery);
 int id =rs.getInt(1);

 String query=" INSERT INTO DEPARTMENTS (ID,E_NAME,A_NAME,SEC_ID) values ("+id+","+p_eName+","+p_aName+","+p_sec_id+")";
 rs = conn.createStatement().executeQuery(query);
   int resultInt= rs.getInt(1);
   return resultInt;
}
$$ [50000-191]
  JdbcSQLException: General error: "java.lang.UnsupportedClassVersionError: org/h2/dynamic/INSERTDEPARTMENT : Unsupported major.minor version 52.0"; SQL statement:
Create Alias InsertDepartment AS $$ 
 int InsertDepartment(Connection conn,String p_eName,String p_aName ,int p_sec_id) throws Exception {

 String IdQuery="SELECT max (id)+1 FROM DEPARTMENTS";
 java.sql.ResultSet rs = conn.createStatement().executeQuery(IdQuery);
 int id =rs.getInt(1);

 String query=" INSERT INTO DEPARTMENTS (ID,E_NAME,A_NAME,SEC_ID) values ("+id+","+p_eName+","+p_aName+","+p_sec_id+")";
 rs = conn.createStatement().executeQuery(query);
   int resultInt= rs.getInt(1);
   return resultInt;
}
$$ [50000-191]
    java.lang.UnsupportedClassVersionError: UnsupportedClassVersionError: org/h2/dynamic/INSERTDEPARTMENT : Unsupported major.minor version 52.0

I have tried alot to find a good examples in the net for stored procedures at the internet ,but not many there also i have read http://h2database.com/html/features.html#user_defined_functions on the H2 site but is so poor and there is no CRUD examples

Dunken
  • 1,311
  • 7
  • 18
  • 30

1 Answers1

0

I have replaced the jre folder inside the dbeaver folder with a a newer jre version and it worked ,but H2 site didnt update their examples .

Dunken
  • 1,311
  • 7
  • 18
  • 30