2 Replies Latest reply on Mar 14, 2006 7:32 PM by max522over

    invalid schema name error

    max522over

      I've generated my skeleton website and I can not find nor insert into the database. I'm using MySql. Here is a table that I'm using:

      CREATE TABLE HEALTHTRACKDB.WeanInformation(
      WeanInformationID VARCHAR (50),
      CalveMarketing VARCHAR(50),
      EstimatedWeanDate VARCHAR(50),
      EstimatedWeanWeight VARCHAR(50),
      PRIMARY KEY (WeanInformationID)
      );

      I generate code for it and deploy it. The website works fine until I try to retrieve or enter data into the database and I get many exceptions but I think this is the one that probably defines my reall problem:


      2006-03-13 18:39:39,312 DEBUG [org.hibernate.jdbc.ConnectionManager] opening JDBC connection
      2006-03-13 18:39:39,312 DEBUG [org.hibernate.SQL] select weaninform0_.WeanInformationID as WeanInfo1_11_0_, weaninform0_.CalveMarketing as CalveMar2_11_0_, weaninform0_.EstimatedWeanDate as Estimate3_11_0_, weaninform0_.EstimatedWeanWeight as Estimate4_11_0_ from healthtrackdb.weaninformation weaninform0_ where weaninform0_.WeanInformationID=?
      2006-03-13 18:39:39,312 INFO [STDOUT] Hibernate: select weaninform0_.WeanInformationID as WeanInfo1_11_0_, weaninform0_.CalveMarketing as CalveMar2_11_0_, weaninform0_.EstimatedWeanDate as Estimate3_11_0_, weaninform0_.EstimatedWeanWeight as Estimate4_11_0_ from healthtrackdb.weaninformation weaninform0_ where weaninform0_.WeanInformationID=?
      2006-03-13 18:39:39,312 DEBUG [org.hibernate.util.JDBCExceptionReporter] could not load an entity: [com.mfa.demo.Weaninformation#990099] [select weaninform0_.WeanInformationID as WeanInfo1_11_0_, weaninform0_.CalveMarketing as CalveMar2_11_0_, weaninform0_.EstimatedWeanDate as Estimate3_11_0_, weaninform0_.EstimatedWeanWeight as Estimate4_11_0_ from healthtrackdb.weaninformation weaninform0_ where weaninform0_.WeanInformationID=?]
      java.sql.SQLException: invalid schema name: HEALTHTRACKDB in statement [select weaninform0_.WeanInformationID as WeanInfo1_11_0_, weaninform0_.CalveMarketing as CalveMar2_11_0_, weaninform0_.EstimatedWeanDate as Estimate3_11_0_, weaninform0_.EstimatedWeanWeight as Estimate4_11_0_ from healthtrackdb.weaninformation weaninform0_ where weaninform0_.WeanInformationID=?]
       at org.hsqldb.jdbc.Util.throwError(Unknown Source)
       at org.hsqldb.jdbc.jdbcPreparedStatement.<init>(Unknown Source)
       at org.hsqldb.jdbc.jdbcConnection.prepareStatement(Unknown Source)
       at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.doPrepareStatement(BaseWrapperManagedConnection.java:346)
       at org.jboss.resource.adapter.jdbc.BaseWrapperManagedConnection.prepareStatement(BaseWrapperManagedConnection.java:334)
       at org.jboss.resource.adapter.jdbc.WrappedConnection.prepareStatement(WrappedConnection.java:187)
       at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:442)
       at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:368)
       at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:105)
       at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1561)
       at org.hibernate.loader.Loader.doQuery(Loader.java:661)
       at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:224)
       at org.hibernate.loader.Loader.loadEntity(Loader.java:1785)
       at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:93)
       at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:81)
       at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:2730)
       at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:365)
       at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:346)
       at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:123)
       at org.hibernate.event.def.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:177)
       at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:87)
       at org.hibernate.impl.SessionImpl.fireLoad(SessionImpl.java:891)
       at org.hibernate.impl.SessionImpl.get(SessionImpl.java:828)
       at org.hibernate.impl.SessionImpl.get(SessionImpl.java:821)
       at org.hibernate.ejb.AbstractEntityManagerImpl.find(AbstractEntityManagerImpl.java:102)
       at com.mfa.demo.WeaninformationEditorBean.create(WeaninformationEditorBean.java:70)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)


        • 1. Re: invalid schema name error
          gavin.king

          Change your persistence.xml to point to a MySQL datasource, instead of the default HSQLDB datasource.

          • 2. Re: invalid schema name error, hooking up mysql for seam/hib
            max522over

            thanks Gavin for pointing me in the right direction. It's working great now.

            here is a website that gave me a bit more information if someone needs it
            http://wiki.jboss.org/wiki/Wiki.jsp?page=SetUpAMysqlDatasource

            what I had to do was copy the
            $JBOSS_HOME/docs/examples/jca/mysql-ds.xml file to $JBOSS_HOME/server/xxx/deploy

            Modify it to look like this

            <datasources>
             <local-tx-datasource>
             <jndi-name>MySqlDS</jndi-name>
             <connection-url>jdbc:mysql://localhost:3309/healthtrackdb</connection-url>
             <driver-class>com.mysql.jdbc.Driver</driver-class>
             <user-name>root</user-name>
             <password>MySQLr0cks</password>
            


            then change my persistence.xml file to

            <entity-manager>
             <persistence-unit name="entityManager">
             <provider>org.hibernate.ejb.HibernatePersistence</provider>
             <jta-data-source>java:/MySqlDS</jta-data-source>
             <properties>
             <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
            


            and finally copy the connector file for mysql to the lib directory of the server.

            Now it's working great