4 Replies Latest reply on Aug 6, 2009 9:45 AM by jaikiran

    Configuring JNDI Datasource (MySQL-5.1.36) in JBOSS 5.1.0GA

    torleif

      I am running eclipse 3.4 with the above MYSQL and JBoss. Now i need to configure JNDI datasource to get all this to work. The problem i have with this is that it is all very new to me so i wonder if there is anybody who can give me some help with this, where to start and how to make this in an easy way for a beginner like my self.

      I have read that i need to do this but i need help with this.
      1. Copy JDBC Driver to $JBOSS_HOME$/server/default/lib/-where is find this?

      2. i copied the sample from $JBOSS_HOME$/docs/examples/jca/mysql-ds.xml
      to $JBOSS_HOME$/server/default/deploy-is this all i need to do?

      So if i get it right i only need to write one xml-file for this or am i wrong? Please help me somebody with this who know this better then i do. Or guide me in the right way where i can read and solve this by my self.

        • 1. Re: Configuring JNDI Datasource (MySQL-5.1.36) in JBOSS 5.1.
          jaikiran

           

          1. Copy JDBC Driver to $JBOSS_HOME$/server/default/lib/-where is find this?


          You mean you want to know where to find the JDBC jar file? Since you mention MySQL, the driver jar will be available here http://dev.mysql.com/downloads/connector/j/5.1.html. After you download that .tar/.zip, extract it to some folder. Inside that you will find a jar (ex: mysql-connector-java-5.1.8-bin.jar). Copy that jar to $JBOSS_HOME/server/default/lib

          2. i copied the sample from $JBOSS_HOME$/docs/examples/jca/mysql-ds.xml
          to $JBOSS_HOME$/server/default/deploy-is this all i need to do?


          You will have to edit it to point to the correct database URL and the user name, password.

          More details about the datasource configuration can be found here:

          http://www.jboss.org/community/wiki/ConfigDataSources

          • 2. Re: Configuring JNDI Datasource (MySQL-5.1.36) in JBOSS 5.1.
            torleif

            I have copied (mysql-connector-java-5.1.7-bin.jar). to $JBOSS_HOME/server/default/lib already so this is done.

            So know i need to copy the $JBOSS_HOME/docs/examples/jca/mysql-ds.xml file to $JBOSS_HOME/server/default/deploy .

            Then when this is done i only need to edit the mysql-ds.xml file. Replace <jndi-name>MySqlDS</jndi-name> with your datasource name,

            Replace <connection-url>jdbc:mysql://mysql-hostname:3306/jbossdb</connection-url> with my connection string,

            and then last username and pasword. Then all this should be finished i hope? Please let me know if this is all i need to do or if there are more things i need to change?

            Thank you very much for your quick replay with this matter. I'll be back again if i don't get this to work but let's hope not. Cheers again for this!!!

            • 3. Re: Configuring JNDI Datasource (MySQL-5.1.36) in JBOSS 5.1.
              torleif

              Replace <jndi-name>MySqlDS</jndi-name> with your datasource name?

              So with the above information what jndi-name should i use? I don't know what i am looking for here so please i need your help again...

              • 4. Re: Configuring JNDI Datasource (MySQL-5.1.36) in JBOSS 5.1.
                jaikiran

                The jndi name can be anything. You just have to remember that name so that you can use it while looking up your datasource in the code.

                So if jndiname is:

                <jndi-name>xyz</jndi-name>


                Then your code to lookup the datasource (within the server) will be:

                Context ctx = new InitialContext();
                DataSource ds = (DataSource) ctx.lookup("java:xyz");