1 Reply Latest reply on Aug 25, 2005 10:06 AM by Colin Reid

    Cant see tables in database

    Colin Reid Newbie

      Hi,

      My environment is Jboss and mySQL.

      I have a JSP which makes use of a stateful session bean. The session bean connects to the database as follows:

      ResultSet rs = null;
      DataSource ds = (DataSource) new javax.naming.InitialContext().lookup("java:comp/env/jdbc/mySQL");
      Connection con = ds.getConnection();
      PreparedStatement statement = con.prepareStatement("select * from theUser");


      For some reason I keep getting the following error:

      org.apache.jasper.JasperException: java.sql.SQLException: Table not found: USER in statement [select * from theUser]


      Th exception is being thrown in the prepareStatement line (the last line above), not even when executing the query . Its as if the table doesnt exist but it certainly does!

      I have been able to connect to this database via servlets, this is the first time Ive tried using a session bean. I have the necessary resource-ref's in ejb-jar.xml and jboss1.xml, and all the JNDI is correct and since mySQL is case sensitive, Ive made sure it matches up. The mySQL jar driver is also installed correclty.

      Since the error occurs before the statement is executed, is this not a problem in that either java or JBoss is returning that the tables dont exist before even accessing thr DB?

      Any ideas?

        • 1. Re: Cant see tables in database
          Colin Reid Newbie

          Ok,

          I drilled down the problem to be that the session EJB is connecting to the hypersonic DB instead of the mySQL one.

          This is very odd behaviur as all the JNDI references in my app are to KestralDB, not DefaultDS - this is true in the java code and all the desployment descriptors. I can confirm the DDs are all correct, as I can access the DB from a servlet in the same app, accesing the DB in the same way.

          Is there something else I have to do to change the database used by the EJB?

          Many thanks,

          colr__