Help with CRYPT_KEY needed

  • elnin0

    elnin0 - 2013-12-05

    I'm trying to get a AES encryption key generation by a HSQLDB database to work. The documentation of this feature is very basic and the only code listing for this task i found here:

    Unfortunately this Code is not working i get a java.sql.SQLException: invalid cursor state: identifier cursor not positioned on row in UPDATE, DELETE, SET, or GET statement: ; ResultSet is empty

    here is the code from the coderanche post:

    SOMETHING HEREClass.forName("org.hsqldb.jdbc.JDBCDriver");
    Connection con = DriverManager.getConnection("jdbc:hsqldb:file:some_db", "SA", "");
    Statement stmt = con.createStatement();  
    ResultSet rs = stmt.executeQuery("select CRYPT_KEY('AES', null) from some_table");;
    String key = rs.getString(1);
  • Lucani

    Lucani - 2013-12-05

    Try this:

            try {
                PreparedStatement stmt = connection.prepareStatement("SELECT CRYPT_KEY('AES', NULL) FROM (VALUES(0))");
                ResultSet rs = stmt.executeQuery();
                String key = rs.getString(1);
            } catch (SQLException e) {
  • Fred Toussi

    Fred Toussi - 2014-01-29

    For interactive use (rather than programmatic), you start DatabaseManager and connect to a new mem: database. You then type this:


    The returned value is displayed in the window. If you click on the View menu and select View as Text, you can highlight and copy the result to the clipboard.


Log in to post a comment.