-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Hibernate configuration of JDBC connection via MD5 or SSL
PostPosted: Thu Oct 13, 2005 12:09 pm 
Newbie

Joined: Thu Oct 13, 2005 11:43 am
Posts: 11
I was wondering how to configure hibernate (using the hibernate.cfg.xml) to tell the JDBC driver to authenticate using a md5 password or using ssl for the communication with the database.

My database (PostgreSQL) does support md5 password authentication and I enabled it in the configuration file. Since doing so I can't connect to the database anymore.

Configuration File:
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
    <session-factory>
        <property name="hibernate.cglib.use_reflection_optimizer">true</property>
        <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
        <property name="hibernate.connection.username">myuser</property>
        <property name="hibernate.connection.password">mypwd</property>
        <property name="hibernate.connection.url">jdbc:postgresql://192.168.1.100:5432/mydb</property>
        <property name="hibernate.default_schema">public</property>
        <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
        <property name="hibernate.hbm2ddl.auto">create</property>
        <property name="hibernate.jdbc.batch_size">20</property>
        <property name="hibernate.show_sql">true</property>
        <mapping resource="test/MyClass.hbm.xml" />
    </session-factory>
</hibernate-configuration>


Hibernate version:
3.0.5

Name and version of the database you are using:
PostgreSQL 8.0.4

Full stack trace of any exception that occurs:
Code:
ERROR [SchemaExport] schema export unsuccessful
org.postgresql.util.PSQLException: FATAL: password authentication failed for user "myuser"
   at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:275)
   at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:94)
   at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65)
   at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:115)
   at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
   at org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
   at org.postgresql.Driver.makeConnection(Driver.java:369)
   at org.postgresql.Driver.connect(Driver.java:245)
   at java.sql.DriverManager.getConnection(DriverManager.java:512)
   at java.sql.DriverManager.getConnection(DriverManager.java:140)
   at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
   at org.hibernate.tool.hbm2ddl.SchemaExport$SuppliedConnectionProviderConnectionHelper.getConnection(SchemaExport.java:414)
   at org.hibernate.tool.hbm2ddl.SchemaExport.execute(SchemaExport.java:176)
   at org.hibernate.tool.hbm2ddl.SchemaExport.create(SchemaExport.java:133)
   at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:299)
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1126)
   ... more
INFO  [SessionFactoryImpl] Checking 0 named queries
WARN  [JDBCExceptionReporter] SQL Error: 0, SQLState: 28000
ERROR [JDBCExceptionReporter] FATAL: password authentication failed for user "myuser"
org.hibernate.exception.GenericJDBCException: Cannot open connection
   at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
   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:314)
   at org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:114)
   at org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:137)
   at org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:57)
   at org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1198)
   ... more
Caused by: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "myuser"
   at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:275)
   at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:94)
   at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65)
   at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:115)
   at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
   at org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
   at org.postgresql.Driver.makeConnection(Driver.java:369)
   at org.postgresql.Driver.connect(Driver.java:245)
   at java.sql.DriverManager.getConnection(DriverManager.java:512)
   at java.sql.DriverManager.getConnection(DriverManager.java:140)
   at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
   at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:311)
   ... more


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 13, 2005 3:09 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
afaik postgressql jdbc driver should handle this transparently thus nothing needed for us (or you) to do on the "client" side; are you sure the password is correctly stored in the db?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 14, 2005 3:20 am 
Newbie

Joined: Thu Oct 13, 2005 11:43 am
Posts: 11
max wrote:
afaik postgressql jdbc driver should handle this transparently thus nothing needed for us (or you) to do on the "client" side; are you sure the password is correctly stored in the db?

Thanks for the reply. It is good to hear that this 'should' be handled transparently. Does it apply for both md5 and ssl?

I'm sure to put in the password correctly since I can login via ssh on the host running the database using the password (and I did no configuration in the pg_ident.conf).

But I guess its a database configuration issue. Will look for this now.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.