Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

bytea data type+EJB2.1  RSS feed

 
geeta Paygude
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

i am using ejb2.1 and PostgreSQL 8.1
i have following query:

I am using bytea data type for password field and my Entity beans getter setter looks like this
/***************************************************************************
* returns Password
*
* @return Blob
**************************************************************************/
public abstract Object getPassword();

/***************************************************************************
* sets Password
*
* @param bPassword
**************************************************************************/
public abstract void setPassword(Object bPassword);


if i write a code to validate password like this:

private boolean validateUser(UserVO oUserVO, UserLocal oUserEntity)
throws InternalServerException
{

final String ALGORITHM = "MD5";
moLogger.debug("oUserVO.getPassword:" + oUserVO.getPassword());
//Encryption of Password
MessageDigest oMessageDigest = null;
try
{
oMessageDigest = MessageDigest.getInstance(ALGORITHM);
oMessageDigest.update(oUserVO.getPassword().getBytes("UTF-8"));
//oMessageDigest.update(oUserVO.getPassword());
byte baRaw[] = oMessageDigest.digest();
//moLogger.debug("Passowrd Obtained from User:"+new String(baRaw));
String szHashPassword = (new BASE64Encoder()).encode(baRaw);
moLogger.debug("Password after hashing.."+szHashPassword);
moLogger.debug("Passowrd Obtained from DB:"+oUserEntity.getPassword());
moLogger.debug("Yeahhh");


}
catch(NoSuchAlgorithmException oNoSuchAlgorithmException)
{

moLogger.error(oNoSuchAlgorithmException.getMessage(), oNoSuchAlgorithmException);
throw new InternalServerException(oNoSuchAlgorithmException.getMessage());
}
catch(UnsupportedEncodingException oUnsupportedEncodingException)
{

moLogger.error(oUnsupportedEncodingException.getMessage(), oUnsupportedEncodingException);
throw new InternalServerException(oUnsupportedEncodingException.getMessage());
}

return true;
}


Then its giving me following Exception:

11:47:05,189 ERROR [LogInterceptor] TransactionRolledbackLocalException in method: public abstract java.lang.Object com.ail.dhg.rcs.business.entity.UserLocal.getPassword(), causedBy:
java.sql.SQLException: Unable to load to deserialize result: java.io.StreamCorruptedException: invalid stream header
at org.jboss.ejb.plugins.cmp.jdbc.JDBCUtil.convertToObject(JDBCUtil.java:290)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCResultSetReader$7.readResult(JDBCResultSetReader.java:193)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCResultSetReader$AbstractResultSetReader.get(JDBCResultSetReader.java:485)
at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.loadArgumentResults(JDBCAbstractCMPFieldBridge.java:463)
at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.loadArgumentResults(JDBCAbstractCMPFieldBridge.java:413)
at org.jboss.ejb.plugins.cmp.jdbc.bridge.JDBCAbstractCMPFieldBridge.loadInstanceResults(JDBCAbstractCMPFieldBridge.java:374)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:193)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCLoadEntityCommand.execute(JDBCLoadEntityCommand.java:74)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity(JDBCStoreManager.java:631)
at org.jboss.ejb.plugins.cmp.jdbc.JDBCStoreManager.loadEntity(JDBCStoreManager.java:613)
at org.jboss.ejb.plugins.CMPPersistenceManager.loadEntity(CMPPersistenceManager.java:391)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.loadEntity(CachedConnectionInterceptor.java:351)
at org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invoke(EntitySynchronizationInterceptor.java:232)
at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:185)





the data which i have in my DB for password field is inserted iusing jdbc

Connection oConnection = DriverManager.getConnection(
"jdbc ostgresql://localhost:5432/rcs", "postgres", "postgres");
String szSqlQuery = "update t_user set password =?";
//String szSelectQuery = "select password from t_user ";
PreparedStatement ps = oConnection.prepareStatement(szSqlQuery);
Statement ps1 = oConnection.createStatement();
ps.setBytes(1,baRaw);
ps.executeUpdate();
ps.close();

or i have tried inserting this string in password field

YuXuX/gmhUOweLBJD1u6Kg==


SO can any one tell me where i am going wrong

my jbosscmp-jdbc.xml has followin field
<cmp-field>
<field-name>password</field-name>
<read-only>false</read-only>
<column-name>password</column-name>
<jdbc-type>VARBINARY</jdbc-type>
<sql-type>BYTEA</sql-type>
</cmp-field>


can any one help me

Regards
Geetanjali Paygude
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!