Dear friends,
I am using Hibernate 3. From following topic, i understood, how to set the encrypted password in the Hibernate config file.
But, it is not working for me.
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.provider_class">org.jasypt.hibernate.connectionprovider.EncryptedPasswordDriverManagerConnectionProvider</property> <property name="hibernate.connection.encryptor_registered_name">configurationHibernateEncryptor</property> <property name="myeclipse.connection.profile">MySQLDriver</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.url">jdbc:mysql://pc1027:3306/licencedb</property>
<property name="connection.username">root</property>
<property name="hibernate.connection.password">KKVX9YcgPs1w/Odh3jrLbg==</property> <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.c3p0.acquire_increment">3</property>
<!-- idle_test_period & Timeout for MySQL Should be less than 28800 (8Hours) -->
<property name="hibernate.c3p0.idle_test_period">14400</property>
<property name="hibernate.c3p0.timeout">14400</property>
<property name="hibernate.c3p0.max_size">10</property>
<property name="hibernate.c3p0.min_size">3</property>
<property name="hibernate.c3p0.preferredTestQuery">select 1;</property>
<mapping resource="com/ocs/lms/dbaccess/dbmapping.xml" />
</session-factory>
</hibernate-configuration>
I have generated the encrypted password ("KKVX9YcgPs1w/Odh3jrLbg==") using command line tool and the command is
encrypt.bat input="MyDBPwd" password=EncryptionPassword algorithm=PBEWithMD5AndDES
I have a static class to give the session to DBServices class. Before configure, i have added the following linces
StandardPBEStringEncryptor strongEncryptor = new StandardPBEStringEncryptor(); strongEncryptor.setAlgorithm("PBEWithMD5AndDES"); strongEncryptor.setPassword("EncryptionPassword"); HibernatePBEEncryptorRegistry registry = HibernatePBEEncryptorRegistry.getInstance(); registry.registerPBEStringEncryptor("configurationHibernateEncryptor", strongEncryptor);
configuration.configure(DBConstants.HIBERNATE_CONFIG_FILE_LOCATION + DBConstants.HIBERNATE_CONFIG_FILE); sessionFactory = configuration.buildSessionFactory();
* [sessionFactory, configuration are static values]
But, DB connection failed with following Exception :
org.hibernate.exception.GenericJDBCException: Cannot open connection at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103) at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43) at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:29) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:426) at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:144) at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:119) at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57) at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1326) Caused by: java.sql.SQLException: Invalid authorization specification message from server: "Access denied for user 'root'@'pc1027.internal.ocs-consulting.com' (using password: YES)" at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1997) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1906) at com.mysql.jdbc.MysqlIO.secureAuth411(MysqlIO.java:2520) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:817) at com.mysql.jdbc.Connection.createNewIO(Connection.java:1786) at com.mysql.jdbc.Connection.<init>(Connection.java:450) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:411) at java.sql.DriverManager.getConnection(Unknown Source) at java.sql.DriverManager.getConnection(Unknown Source) at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110) at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:423)
But, when i remove the encrypted password and give right password in the hibernate config file, it works fine.
Please help me to find, which step, i am missing.
_________________ SANSFWDS
|