1 Reply Latest reply on Oct 6, 2011 2:58 PM by noelmarin

    Problem changing database name on datasource - JBoss AS 6

    noelmarin

      Hi everybody,

       

      I'm having a weird problem with a simple change in my datasource on JBoss AS 6, I'm changing the database name of my app, but when I deploy it and run the server it takes the old database, I don't know what I'm doing wrong, I'm using hibernate.

       

      This is the original datasource:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <datasources>

        <local-tx-datasource>

        <jndi-name>ThotMainDS</jndi-name>

        <connection-url>jdbc:jtds:sqlserver://localhost/THOT</connection-url>

        <driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>

        <user-name>sa</user-name>

        <password>pass</password>

        <check-valid-connection-sql>SELECT 1 FROM sysobjects</check-valid-connection-sql>

        <metadata>

            <type-mapping>MS SQLSERVER2008</type-mapping>

        </metadata>

        </local-tx-datasource>

      </datasources>

       

      After I change the database name:

       

      <?xml version="1.0" encoding="UTF-8"?>

      <datasources>

        <local-tx-datasource>

        <jndi-name>ThotMainDS</jndi-name>

        <connection-url>jdbc:jtds:sqlserver://localhost/THOTDEV</connection-url>

        <driver-class>net.sourceforge.jtds.jdbc.Driver</driver-class>

        <user-name>sa</user-name>

        <password>pass</password>

        <check-valid-connection-sql>SELECT 1 FROM sysobjects</check-valid-connection-sql>

        <metadata>

            <type-mapping>MS SQLSERVER2008</type-mapping>

        </metadata>

        </local-tx-datasource>

      </datasources>

       

      This is my persistence.xml

       

      <persistence xmlns="http://java.sun.com/xml/ns/persistence"

                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                   xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"

                   version="2.0">

         <persistence-unit name="ThotPersistenceUnit">

            <jta-data-source>java:/ThotMainDS</jta-data-source>

            <properties>

               <property name="hibernate.dialect" value="org.hibernate.dialect.SQLServerDialect" />

               <property name="hibernate.hbm2ddl.auto" value="validate" />

            </properties>

         </persistence-unit>

      </persistence>

       

      If I put a wrong database name, some that doesn't exist, the server shows the error.

       

      Please help me, I'm stuck, thank you already

        • 1. Re: Problem changing database name on datasource - JBoss AS 6
          noelmarin

          Finally I got the solution, It was too simple for the problem It produced to me,

           

          Every single entity bean had a annotation named table (@Table), that annotation had a property named catalog and the value of that property was the database name, even i changed the database name in the datasource hibernate didn't take that change because that property, so the solution was delete it.

           

          That's it, I lost a lot of hours of work because of that.

           

          Thank you all