4 Replies Latest reply on Feb 22, 2004 3:53 AM by pilhuhn

    I'be got the connection, but why can't find table?

    matafy

      Thanks for reading this.
      I've got a problem when using jboss to deploy a BMP and my database is mysql.
      The problem is I've got the connection successfully, but when
      I execute a query why it report an error:the table is not found.

      pstmt = conn.prepareStatement( "select sum(balance) as total from test.account" );

      I'm sure this table is in the database.I'm puzzled.

        • 1. Re: I'be got the connection, but why can't find table?
          matafy

          who can help me???

          • 2. Re: I'be got the connection, but why can't find table?
            matafy

            Maybe i didn't describe it detailly enough.
            To config the datasource, i have modified two files.
            One is "standardjbosscmp-jdbc.xml" which is the default one that i havn't change after installing jboss, i modified the following lines:
            <jbosscmp-jdbc>

            java:/mySqlDS <datasource-mapping>ejbstudy</datasource-mapping>
            ....
            The other file is "mysql-service.xml". I copy it from conf/.. to deploy directory, and only modify the following line:
            <config-property name="ConnectionURL" type="java.lang.String">jdbc:mysql://localhost</config-property>

            In ejb-jar.xml, i add the following lines:
            <resource-ref>
            <res-ref-name>mySqlDS</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
            </resource-ref>

            There is a database named ejbstudy, which is exactly has a table "account".

            In bean files:
            PreparedStatement pstmt = null;
            Connection conn = null;
            try
            {
            System.out.println( "ejbHomeGetTotalBankValue()" );
            conn = getConnection();
            System.out.println(conn.toString());
            pstmt = conn.prepareStatement( "select balance from account" );
            ResultSet rs = pstmt.executeQuery();
            ...

            when executing , following error occurs:
            08:45:46,258 INFO [Server] JBoss (MX MicroKernel) [3.0.7 (CVSTag=JBoss_3_0_7 Da
            te=200304081816)] Started in 1m:10s:802ms
            08:47:36,507 INFO [STDOUT] New Bank Account Entity Bean Java Object created by
            EJB Container.
            08:47:36,557 INFO [STDOUT] setEntityContext() called
            08:47:36,577 INFO [STDOUT] ejbHomeGetTotalBankValue()
            08:47:36,587 INFO [STDOUT] get connection!
            08:47:37,007 INFO [STDOUT] org.jboss.resource.adapter.jdbc.WrappedConnection@88
            6ad0
            08:47:37,118 ERROR [STDERR] java.sql.SQLException: Table not found: ACCOUNT in s
            tatement [select balance from account]
            08:47:37,138 ERROR [STDERR] at org.hsqldb.Trace.getError(Trace.java:180)
            08:47:37,138 ERROR [STDERR] at org.hsqldb.Result.(Result.java:175)
            08:47:37,138 ERROR [STDERR] at org.hsqldb.jdbcConnection.executeHSQL(jdbcCon
            nection.java:907)
            08:47:37,158 ERROR [STDERR] at org.hsqldb.jdbcConnection.execute(jdbcConnect
            ion.java:718)
            08:47:37,158 ERROR [STDERR] at org.hsqldb.jdbcStatement.fetchResult(jdbcStat
            ement.java:686)
            08:47:37,158 ERROR [STDERR] at org.hsqldb.jdbcStatement.executeQuery(jdbcSta
            tement.java:68)
            08:47:37,168 ERROR [STDERR] at org.hsqldb.jdbcPreparedStatement.executeQuery
            (jdbcPreparedStatement.java:133)
            08:47:37,168 ERROR [STDERR] at org.jboss.resource.adapter.jdbc.WrappedPrepar
            edStatement.executeQuery(WrappedPreparedStatement.java:289)
            08:47:37,168 ERROR [STDERR] at com.xinli.account.AccountBean.ejbHomeGetTotal
            BankValue(AccountBean.java:94)
            08:47:37,168 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(
            Native Method)

            • 3. Re: I'be got the connection, but why can't find table?
              matafy

              Sorry, modified lines in standardjbosscmp-jdbc.xml are:
              <jbosscmp-jdbc>

              java:/mySqlDS
              <datasource-mapping>ejbstudy</datasource-mapping>
              <create-table>true</create-table>

              • 4. Re: I'be got the connection, but why can't find table?
                pilhuhn

                <datasource-mapping>ejbstudy</datasource-mapping>
                is bogus as long as there is no db-mapping named 'ejbstudy' in standardjbosscmp-jdbc.xml.
                Try 'mySQL' instead.