Hmmm, not sure what you are trying to achieve but...

- You are using CALL ... so should be using a CallableStatement rather
than a PreparedStatement ?
- You are using STRINGTOUTF8(?) ... on a byte[] (which is not a
string)

Note: I'm using ENCRYPT(...) with insert/update statements.

Maybe that helps.

On Jan 25, 1:42 am, Thotheolh <[email protected]> wrote:
> Hi. I have a code to execute encryption via SQL prepared statement.
> The code fragment is below. I am doing it right ?
>
> public byte[] encrypt(byte[] keyBytes, byte[] data){
>         try {
>             PreparedStatement pstmt = getConn().prepareStatement("CALL
> ENCRYPT('AES', ?, STRINGTOUTF8(?))");
>             pstmt.setBytes(1, keyBytes);
>             pstmt.setBytes(2, data);
>             ResultSet rs = pstmt.executeQuery();
>             return rs.getBytes(0); //What should it return ?
>         } catch (SQLException ex) {
>             Logger.getLogger(SQLManager.class.getName()).log
> (Level.SEVERE, null, ex); //Logging
>             return null;
>         }
>     }
>
> What does it return in the ResultSet ? Do I rs.getBytes(0); or what is
> the column name I should get ?

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to