0 Replies Latest reply on Apr 27, 2004 10:02 PM by tomjc

    strange database connection - mysql

    tomjc Newbie

      I'm trying to set up and run the forethoughtEntities code from the
      O'Reilly book by Brett McLaughlin, and am running into a strange
      issue when I connect.
      I put code in the SequenceBean (the one that gets the next valid
      key for any given table in the database) to display when the datasource
      is set up, when I get a connection, and to list the tables in the
      datasource after the connection is made.

      On the JBoss console, I'm getting:
      --------------------------------------------------------------------------
      22:00:56,201 INFO [STDOUT] SequenceBean: datasource: org.jboss.resource.adapte
      r.jdbc.WrapperDataSource@fe0fd9
      22:00:56,491 INFO [STDOUT] SequenceBean: got connection: org.jboss.resource.ada
      pter.jdbc.WrappedConnection@25a893
      22:00:56,772 INFO [STDOUT] SequenceBean: connection product: HSQL Database En
      gine
      22:00:57,052 INFO [STDOUT] SequenceBean: table in db: JETTY_HTTPSESSION_CM
      PSTATE
      22:00:57,333 INFO [STDOUT] SequenceBean: table in db: CMPBEAN
      22:00:57,473 INFO [STDOUT] SequenceBean: table in db: BMP_BEAN_TBL
      22:00:57,613 INFO [STDOUT] SequenceBean: table in db: READONLY
      22:00:57,763 INFO [STDOUT] SequenceBean: table in db: ENTITYEXC
      22:00:57,903 INFO [STDOUT] SequenceBean: table in db: IDCOUNTER
      22:00:58,044 INFO [STDOUT] SequenceBean: table in db: PUBLISHERCMP
      22:00:58,184 INFO [STDOUT] SequenceBean: table in db: ENTITYA
      22:00:58,314 INFO [STDOUT] SequenceBean: table in db: ENTITYB
      22:00:58,454 INFO [STDOUT] SequenceBean: table in db: ENTERPRISEENTITY_B
      22:00:58,594 INFO [STDOUT] SequenceBean: table in db: ENTERPRISEENTITY_B_M
      ULTI
      22:00:58,875 INFO [STDOUT] SequenceBean: table in db: ENTERPRISEENTITY_C
      22:00:59,015 INFO [STDOUT] SequenceBean: table in db: ENTERPRISEENTITY_C_M
      ULTI
      22:00:59,295 INFO [STDOUT] SequenceBean: table in db: ENTERPRISEENTITY_D
      22:00:59,436 INFO [STDOUT] SequenceBean: table in db: ENTERPRISEENTITY_A
      22:00:59,576 INFO [STDOUT] SequenceBean: table in db: PROXYCOMPILERTEST
      22:00:59,716 INFO [STDOUT] SequenceBean: table in db: ADDRESS
      22:00:59,856 INFO [STDOUT] SequenceBean: table in db: CMPFINDTESTENTITY
      22:00:59,996 INFO [STDOUT] SequenceBean: table in db: NEXTGEN_ENTERPRISEEN
      TITY
      22:01:00,277 INFO [STDOUT] SequenceBean: table in db: NEXTGEN_ENTITYPK
      22:01:00,427 INFO [STDOUT] SequenceBean: table in db: ENTITY
      22:01:00,567 INFO [STDOUT] SequenceBean: table in db: PRINCIPALS
      22:01:00,708 INFO [STDOUT] SequenceBean: table in db: ROLES
      22:01:00,848 INFO [STDOUT] SequenceBean: table in db: ACCOUNT
      22:01:00,988 INFO [STDOUT] SequenceBean: table in db: CUSTOMER
      22:01:01,128 INFO [STDOUT] SequenceBean: table in db: PERF_ENTITY2
      22:01:01,268 INFO [STDOUT] SequenceBean: table in db: PERF_CLIENTENTITY
      22:01:01,409 INFO [STDOUT] SequenceBean: table in db: PERF_ENTITY
      22:01:01,549 INFO [STDOUT] SequenceBean: table in db: ADDRESSEJB
      22:01:01,689 INFO [STDOUT] SequenceBean: table in db: ACCOUNTHOLDEREJB
      22:01:01,829 INFO [STDOUT] SequenceBean: table in db: ACCOUNTEJB
      22:01:01,969 INFO [STDOUT] SequenceBean: table in db: OFFICE
      22:01:02,110 INFO [STDOUT] SequenceBean: executing query: org.jboss.resource.ad
      apter.jdbc.WrappedPreparedStatement@9824aa
      --------------------------------------------------------------------------

      On the EntityCreator (client program) output, I get:

      >java com.forethought.client.EntityCreator

      McLaughlin Forethought EntityCreator program.

      setting security policy...
      got InitialContext...
      ...is: [javax.naming.InitialContext@443226]
      Looking up the Office bean.
      got context...
      refobj = OfficeHome
      create DallasOffice...
      Error in EntityCreator: Error getting primary key value: Sequence Bean Exception
      : Error in SQL: Table not found: PRIMARY_KEYS in statement [select next_value fr
      om primary_keys where key_name = 'OFFICES']: Table not found: PRIMARY_KEYS in st
      atement [select next_value from primary_keys where key_name = 'OFFICES']

      C:\dl\Coding\Java\Ejb\McLaughlin
      >

      ....it seems obvious I'm not getting connected to the correct
      database, but no database that is set up in mysql has these
      tables. I'm an EJB newbie and trying to figure out how I'm
      going wrong.

      my server.policy and jndi.properties are in the same dir
      where I run the client, and they seem correct.

      I look up the database context with:

      DataSource ds =
      (DataSource)
      context.lookup("java:/comp/env/jdbc/forethoughtDB");

      ..and my ejb-jar.xml has in the section:

      <resource-ref>
      Connection to the Forethought database.
      <res-ref-name>jdbc/forethoughtDB</res-ref-name>
      <init-param driver-name="com.mysql.jdbc.Driver"/>
      <init-param user=""/>
      <init-param password=""/>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
      </resource-ref>

      ....everything seems like it should be, but I'm still apparently
      getting a wrong connection.
      I have, on the server side, the mysql-connector-java-3.0.10-stable-bin.jar,
      in the j2sdk\jre\lib\ext dir, and it's in the classpath.

      in the database, I have tables:
      mysql> show tables;
      +-------------------------+
      | Tables_in_forethoughtdb |
      +-------------------------+
      | account_types |
      | accounts |
      | attendees |
      | events |
      | funds |
      | investments |
      | offices |
      | primary_keys |
      | transactions |
      | user_types |
      | users |
      +-------------------------+


      Has anyone else seen this ? I've tried to find either a connection
      or datasource method to show me the database that I have
      connected to, but I cannot find any such.

      Thanks for any advice.