8 Replies Latest reply on Jan 12, 2009 10:10 AM by mfps1810

    JBoss Datasource reads an old connection-url

      Hi,

      I have created an own datasource called test-ds.xml.

      First time, it had a local-tx-datasource with next parameters:

      - jndi-name : testDS
      - connection-url : jdbc:mysql://10.90.31.14:3306/test

      It works ok. But now, I have created a new mySQL instance with the name 'testB'. I have changed the datasource and now it has this parameters:

      - jndi-name : testDS
      - connection-url : jdbc:mysql://10.90.31.14:3306/testB

      After Jboss has started, when I run my web-app it uses the old database (test) but on the datasource file, the connection-url's name is testB.

      Any ideas?

      Thanks.

      Manuel.

        • 1. Re: JBoss Datasource reads an old connection-url
          peterj

          Are you sure that the correct *-ds.xml file is in server/xxx/deploy? Did you restart the app server?

          Look in the server.log file for a line that looks like this:

          2008-11-11 15:04:49,889 DEBUG [org.jboss.deployment.MainDeployer] Starting deployment of package: file:/jboss_home/server/xxx/deploy/yyy-ds.xml

          Following that there should several lines that describe the mbeans created from the *-ds.xml file. One of the lines contains the database url:

          <config-property name='ConnectionURL' type='java.lang.String'>xxxxxxx</config-property>


          Another thought - does the account in mysql have access rights to testB?


          • 2. Re: JBoss Datasource reads an old connection-url

            Hi, thanks for the reply.
            I've restarted the App Server and then I've looked into the server.log file.

            It has this line:

            " <config-property name='ConnectionURL' type='java.lang.String'>jdbc:mysql://10.90.31.14:3306/testB?useUnicode=true&amp;characterEncoding=UTF-8</config-property> "

            But when I start my web app, it has loaded the database called 'test', not 'testB'.

            Thanks,

            Manuel.

            • 3. Re: JBoss Datasource reads an old connection-url
              jaikiran

               

              "mfps1810" wrote:

              But when I start my web app, it has loaded the database called 'test', not 'testB'.



              What steps do you follow to verify that?

              • 4. Re: JBoss Datasource reads an old connection-url


                1. C:\jboss-4.2.2.GA\server\default\deploy\my-ds.xml

                <?xml version="1.0"?>

                <local-tx-datasource>
                <jndi-name>imceDS</jndi-name>
                <connection- url>jdbc:mysql://10.90.31.14:3306/testB</connection-url>
                <driver-class>org.gjt.mm.mysql.Driver</driver-class>
                <user-name>root</user-name>
                xxx
                <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
                <max-pool-size>20</max-pool-size>
                <idle-timeout-minutes>5</idle-timeout-minutes>

                <type-mapping>mySQL</type-mapping>

                </local-tx-datasource>


                2. C:\jboss-4.2.2.GA\bin\run.bat

                12:23:57,703 INFO [Server] JBoss (MX MicroKernel) [4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)] Started in 1m:56s:859ms...

                3. Edit server.log



                <config-property name='ConnectionURL' type='java.lang.String'>jdbc:mysql://10.90.31.14:3306/testB</config-property>
                <config-property name='DriverClass' type='java.lang.String'>org.gjt.mm.mysql.Driver</config-property>
                <config-property name='UserName' type='java.lang.String'>root</config-property>
                <config-property name='Password' type='java.lang.String'>imce</config-property>
                <config-property name='ExceptionSorterClassName' type='java.lang.String'>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</config-property>
                <config-property name='ValidateOnMatch' type='boolean'>true</config-property>



                4. Run my web app

                http://localhost:8080/mywebapp/

                The database called test has been loaded, not the database testB !!!!!

                That's all!

                Thanks,

                Manuel.

                • 5. Re: JBoss Datasource reads an old connection-url
                  jaikiran

                   

                  The database called test has been loaded, not the database testB !!!!!


                  Let me be more clear :)
                  In your webapplication do you load the data and show it on the page? And this data which is shown on the page belongs to the "test" database and not the "testB"? If that's what is happening, please post the code where you are loading the data (i.e. accessing the datasource and using it to get the data from database). Is there hibernate involved in your application? If yes, then please post the contents of a hbm.xml file and the hibernate.cfg.xml.

                  While posting logs or xml content or code, please remember to wrap it in a code block by using the Code button in the message editor window. Please use the Preview button to ensure that your post is correctly formatted.

                  • 6. Re: JBoss Datasource reads an old connection-url

                    Ok, I've seen the problem.

                    In every hbm.xml file, the catalog was referenced to the old database.

                    I've changed it and now it works correctly.

                    Thanks,

                    Manuel.

                    • 7. Re: JBoss Datasource reads an old connection-url
                      jaikiran

                       

                      "mfps1810" wrote:


                      In every hbm.xml file, the catalog was referenced to the old database.



                      I have seen many users running into this specific issue :) That's the reason why it's better to never set that catalog in hbm.xml. If for some reason, someone else in a shared project uses your hbm files and does not change that value to point to his DB, then there are chances that he might (unintentionally) end up messing up your database. Any moreover, adding that catalog value to every hbm, isn't worth the efforts.



                      • 8. Re: JBoss Datasource reads an old connection-url

                        Thanks jaikiran,

                        Your last post has a very usefull explanation about why isn't good to use 'catalog' in hbm files.

                        Manuel.