I have DB2 table which has a column holding encrypted passwords of data type VARCHAR FOR BIT DATA
i am able to store the password in this column using DB2 encrypt() function,so far so good,the trouble is when i try to read that password back using DB2 decrypt_char()
function,i am trying to do that using a Named Native SQL Query like the one below
FROM <table name>
WHERE LCASE(USER_EMAIL_ADDRESS) = :emailId
this gives me an exception and i am only posting the lines that are significant from the stack trace
Caused by: org.hibernate.exception.GenericJDBCException: could not execute query
Caused by: com.ibm.db2.jcc.b.SqlException: [ibm][db2][jcc] Invalid parameter: Unknown column name TEMP_PASSWORD.
i dont understand why,because not only is the column in present in the table but also the mapping is perfect in the hbm.xml
btw i am using a JDBC Type 4 driver and DB2 V9
The exception seems to be thrown by DB2, rather than Hibernate so i would suspect issue with SQL. It seems very obvious & in all probability you would have tried this but i will still ask - Were you able to execute query from SQL prompt?
Yes it works from the console,its in fact a pretty straight forward SQL,but somehow dosen't work with Hibernate,all i can say that Hibernate has got a problem handling VARCHAR FOR BIT DATA fields in DB2,the problem may be with the type of JDBC driver too,anyways i found a workaround for this problem after a few ruined weekends:-)
Well,my requirement was to decrypt the password to check if it matches what the user enters,since i was not able to do that,i get the encrypted form of the password user enters and compare it to the value in the table,this way i don't have to deal with the decrypting stuff,not a great idea but it works
I'm all tasted up for a BLT! This tiny ad wants a monte cristo!
a bit of art, as a gift, that will fit in a stocking