0 Replies Latest reply on Dec 13, 2009 11:43 PM by Roland Roberts

    How to do Password Lookup when creating new Connection?

    Roland Roberts Newbie

      We have a standalone application which using Hibernate and Spring but which we would like to move into JBoss.  A key part of the application involves generating connections via a custom ConnectionProvider which calls our customer DataSource which includes code to look up the database user password whenever a connection is created.  For various reasons having to do with audit compliance, we have to keep the password separate from the code/configuration which means we also have to have some bit of password lookup code in there.


      I've been searching, but my google-fu has failed me on this one.  I can't figure out how to get my own ConnetionProvider to be used when using HIbernate in JBoss and my attempts so far have failed.  Here's my hibernate configuration:


      <?xml version='1.0' encoding='utf-8'?>
      <!DOCTYPE hibernate-configuration PUBLIC
              "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
           <session-factory name="java:mydb/drpgSessionFactory">
                <property name="connection.provider_class">my.util.MyConnectionProvider</property>
                <property name="connection.URL">jdbc:postgresql:mydb</property>
                <property name="connection.databaseName">${db.name}</property>
                <property name="connection.user">${db.user}</property>
                <property name="connection.pass"></property>
                <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
                <property name="hibernate.hbm2ddl.auto">verify</property>
                <property name="hibernate.show_sql">false</property>
                <property name="hibernate.default_schema">myapp</property>


      Those funny parameters ${db.user} get handled via the custom ConnectionProvider.  Or they would if only it were called.


      I don't really care about using a custom ConnectionProvider versus some other solution, I just need to understand how I can get the connection creation intercepted so that I can do the password lookup.  Can someone give me a clue?