4 Replies Latest reply on Jan 11, 2006 2:12 PM by ejb3workshop

    Connection properties via @Ressource

    martinganserer

      Hello,

      how can I get specific connection properties like username or password via Ressource-Injection?

      Thank you!

        • 1. Re: Connection properties via @Ressource
          ejb3workshop

          Hi Martin,

          Can you just make sure you use @Resource rather then @Ressource like you mentioned in the subject. Might have just been a typo, I hope. The connection details are specified in a JDBC Datasource configuration file which you need to deploy.

          Here is an example of a PostgreSQL one (postgres-ds.xml):


          <?xml version="1.0" encoding="UTF-8"?>
          <datasources>
          <local-tx-datasource>
          <jndi-name>PostgresDS</jndi-name>
          <connection-url>jdbc:postgresql://localhost:5432/jboss</connection-url>
          <driver-class>org.postgresql.Driver</driver-class>
          <user-name>userid</user-name>
          <password> password </password>
          </local-tx-datasource>
          </datasources>


          Just make sure the drivers are installed into the lib directory. The xml file shown above goes into the deploy directory. Then all you need to do is to specify the Resource by name.


          • 2. Re: Connection properties via @Ressource
            ejb3workshop

            it should have read as :

            <datasources>
             <local-tx-datasource>
             <jndi-name>PostgresDS</jndi-name>
             <connection-url>jdbc:postgresql://localhost:5432/jboss</connection-url>
             <driver-class>org.postgresql.Driver</driver-class>
             <user-name>postgres</user-name>
             <password>postgres</password>
             </local-tx-datasource>
            
            </datasources>


            • 3. Re: Connection properties via @Ressource
              martinganserer

              Hi,

              thank you. But I didn't mean the database connection settings.
              I would like to get username and password of the app server connection.

              Thanks

              • 4. Re: Connection properties via @Ressource
                ejb3workshop

                Are you talking about the JAAS Principal ?

                Alex