Burkhard,
Thank you for your reply. I have made the configuration change that you
showed me and have redeployed the bean.
However, it still crashes with the same message. Here is a look at the sql
stm from the java code...Also, I took out the reference to the database
test.Ship, where test is the database name and Ship is the name of the table.
It now reads, simply, Ship. It crashes either way, but I thought this made
more sense since the URL (see below in jboss.jcml) references the test
database. Also, I have created table test.Ship, TEST.SHIP, Test.Ship,
test.ship where test is always the name of the database within MySQL but It
still won't insert the row. Any suggestions?
Thanks in advance,
Scott
Change to jboss.xml
entity>
<ejb-name>ShipBean</ejb-name>
<resource-ref>
<res-ref-name>jdbc/mySQLDB</res-ref-name> <!-- no : -->
<resource-name>java:/mySQLDB</resource-name>
</resource-ref>
</entity>
public ShipPK ejbCreate(int id, String name, int capacity, double tonnage)
throws CreateException{
if((id < 1) || (name == null))
throw new CreateException("Invalid Parameters");
this.id = id;
this.name = name;
this.capacity = capacity;
this.tonnage = tonnage;
Connection con = null;
PreparedStatement ps = null;
try {
con = this.getConnection();
ps = con.prepareStatement(
******************************************************************************
******
"insert into Ship (id, name, capacity, tonnage) " +
"values (?,?,?,?)");
******************************************************************************
******
ps.setInt(1, id);
ps.setString(2, name);
ps.setInt(3, capacity);
ps.setDouble(4, tonnage);
if (ps.executeUpdate() != 1) {
throw new CreateException ("Failed to add Ship to database");
}
ShipPK primaryKey = new ShipPK();
primaryKey.id = id;
return primaryKey;
}
catch (SQLException se) {
throw new EJBException(se);
}
finally {
try {
if (ps != null) ps.close();
if (con!= null) con.close();
} catch(SQLException se){
se.printStackTrace();
}
}
}
Here is the error as it appears now...
[ShipBean] TRANSACTION ROLLBACK EXCEPTION:null; nested exception is:
javax.ejb.EJBException
[ShipBean] java.sql.SQLException: Table not found: SHIP in statement [insert
into Ship (id, name, capacity, tonnage) values (1,'Paradise',3000,100000.0)]
[ShipBean] at org.hsql.Trace.getError(Trace.java:124)
[ShipBean] at org.hsql.Result.<init>(Result.java:70)
[ShipBean] at
org.hsql.jdbcConnection.executeHSQL(jdbcConnection.java:644)
[ShipBean] at org.hsql.jdbcConnection.execute(jdbcConnection.java:540)
[ShipBean] at org.hsql.jdbcStatement.fetchResult(jdbcStatement.java:499)
[ShipBean] at org.hsql.jdbcStatement.executeUpdate(jdbcStatement.java:52)
[ShipBean] at
org.hsql.jdbcPreparedStatement.executeUpdate(jdbcPreparedStatement.java:114)
[ShipBean] at
org.opentools.minerva.jdbc.PreparedStatementInPool.executeUpdate(PreparedState
mentInPool.java:82)
[ShipBean] at com.titan.shipbmp.ShipBean.ejbCreate(ShipBean.java:48)
[ShipBean] at java.lang.reflect.Method.invoke(Native Method)
[ShipBean] at
org.jboss.ejb.plugins.BMPPersistenceManager.createEntity(BMPPersistenceManager
.java:121)
[ShipBean] at
org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:441)
[ShipBean] at java.lang.reflect.Method.invoke(Native Method)
[ShipBean] at
org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContainer.
java:639)
[ShipBean] at
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySynchr
onizationInterceptor.java:160)
[ShipBean] at
org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInter
ceptor.java:87)
[ShipBean] at
org.jboss.ejb.plugins.TxInterceptorCMT.invokeNext(TxInterceptorCMT.java:135)
[ShipBean] at
org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.ja
va:263)
[ShipBean] at
org.jboss.ejb.plugins.TxInterceptorCMT.invokeHome(TxInterceptorCMT.java:86)
[ShipBean] at
org.jboss.ejb.plugins.SecurityInterceptor.invokeHome(SecurityInterceptor.java:
164)
[ShipBean] at
org.jboss.ejb.plugins.LogInterceptor.invokeHome(LogInterceptor.java:106)
[ShipBean] at
org.jboss.ejb.EntityContainer.invokeHome(EntityContainer.java:316)
[ShipBean] at
org.jboss.ejb.plugins.jrmp.server.JRMPContainerInvoker.invokeHome(JRMPContaine
rInvoker.java:369)
[ShipBean] at java.lang.reflect.Method.invoke(Native Method)
[ShipBean] at
sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:241)
[ShipBean] at sun.rmi.transport.Transport$1.run(Transport.java:142)
[ShipBean] at java.security.AccessController.doPrivileged(Native Method)
[ShipBean] at sun.rmi.transport.Transport.serviceCall(Transport.java:139)
[ShipBean] at
sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:443)
[ShipBean] at
sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:643
)
[ShipBean] at java.lang.Thread.run(Thread.java:484)
Reply-To: [EMAIL PROTECTED]
1 error so below:
----- Original Message -----
From: "Scott Salisbury" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 09, 2001 11:35 PM
Subject: [JBoss-user] MySQL, BMP, Table not found
Hello,
I am using the O'Reilly book to familiarize with EJB. I am using JBOSS
2.2.1 with Tomcat 3.2.1. I am able to get CMP beans to work using MySQL
without a problem however when I try to insert a row using BMP I get the
following message..
Table not found: TEST.SHIP in statement [insert into test.Ship (id, name,
capacity, tonnage) values (4,'UtopiaBMP',4500,8939.0)]
The table is there. I am using MySQL but I have a feeling that JBOSS is
trying to write to InstantDB or Hypersonic. I have included configuration
files below.
I have reviewed the archives but still can't figure it out. What have I
missed?
[ShipBean] TRANSACTION ROLLBACK EXCEPTION:null; nested exception is:
javax.ejb.EJBException
[ShipBean] java.sql.SQLException: Table not found: TEST.SHIP in statement
[insert into test.Ship (id, name, capacity, tonnage) values
(4,'UtopiaBMP',4500,8939.
0)]
[ShipBean] at org.hsql.Trace.getError(Trace.java:124)
[ShipBean] at org.hsql.Result.<init>(Result.java:70)
[ShipBean] at
org.hsql.jdbcConnection.executeHSQL(jdbcConnection.java:644)
[ShipBean] at org.hsql.jdbcConnection.execute(jdbcConnection.java:540)
[ShipBean] at
org.hsql.jdbcStatement.fetchResult(jdbcStatement.java:499)
[ShipBean] at
org.hsql.jdbcStatement.executeUpdate(jdbcStatement.java:52)
[ShipBean] at
org.hsql.jdbcPreparedStatement.executeUpdate(jdbcPreparedStatement.java:114)
[ShipBean] at
org.opentools.minerva.jdbc.PreparedStatementInPool.executeUpdate(PreparedSta
tementInPool.java:82)
[ShipBean] at com.titan.shipbmp.ShipBean.ejbCreate(ShipBean.java:48)
[ShipBean] at java.lang.reflect.Method.invoke(Native Method)
[ShipBean] at
org.jboss.ejb.plugins.BMPPersistenceManager.createEntity(BMPPersistenceManag
er.java:121)
[ShipBean] at
org.jboss.ejb.EntityContainer.createHome(EntityContainer.java:441)
[ShipBean] at java.lang.reflect.Method.invoke(Native Method)
[ShipBean] at
org.jboss.ejb.EntityContainer$ContainerInterceptor.invokeHome(EntityContaine
r.java:639)
[ShipBean] at
org.jboss.ejb.plugins.EntitySynchronizationInterceptor.invokeHome(EntitySync
hronizationInterceptor.java:160)
[ShipBean] at
org.jboss.ejb.plugins.EntityInstanceInterceptor.invokeHome(EntityInstanceInt
erceptor.java:87)
JNDI Code within the bean
private Connection getConnection() throws SQLException {
try {
Context jndiCntx = new InitialContext();
DataSource ds =
(DataSource)jndiCntx.lookup("java:comp/env/jdbc/mySQLDB");
return ds.getConnection();
}
catch (NamingException ne) {
throw new EJBException(ne);
}
}
JDBC section of jboss.jcml
<!-- JDBC -->
<mbean code="org.jboss.jdbc.JdbcProvider"
name="DefaultDomain:service=JdbcProvider">
<attribute
name="Drivers">org.hsql.jdbcDriver,org.enhydra.instantdb.jdbc.idbDriver,org.
gjt.mm.mysql.Driver</attribute>
</mbean>
<mbean code="org.jboss.jdbc.XADataSourceLoader"
name="DefaultDomain:service=XADataSource,name=mySQLDB">
<attribute
name="DataSourceClass">org.opentools.minerva.jdbc.xa.wrapper.XADataSourceImp
l</attribute>
<attribute name="PoolName">mySQLDS</attribute>
<attribute name="URL">jdbc:mysql://165.121.243.05/test</attribute>
<attribute name="JDBCUser" />
<attribute name="Password" />
</mbean>
ejb-jar.xml
<?xml version="1.0"?>
<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise
JavaBeans 1.1//EN" "http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd">
<ejb-jar>
<enterprise-beans>
<entity>
<description>
This bean represents a cruise ship.
</description>
<ejb-name>ShipBean</ejb-name>
<home>com.titan.shipbmp.ShipHome</home>
<remote>com.titan.shipbmp.Ship</remote>
<ejb-class>com.titan.shipbmp.ShipBean</ejb-class>
<persistence-type>Bean</persistence-type>
<prim-key-class>com.titan.shipbmp.ShipPK</prim-key-class>
<reentrant>False</reentrant>
<resource-ref>
<description>DataSource for the Titan database</description>
<res-ref-name>jdbc/mySQLDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
</entity>
</enterprise-beans>
<assembly-descriptor>
<security-role>
<description>
This role represents everyone who is allowed full access
to the Ship bean.
</description>
<role-name>everyone</role-name>
</security-role>
<method-permission>
<role-name>everyone</role-name>
<method>
<ejb-name>ShipBean</ejb-name>
<method-name>*</method-name>
</method>
</method-permission>
<container-transaction>
<method>
<ejb-name>ShipBean</ejb-name>
<method-name>*</method-name>
</method>
<trans-attribute>Required</trans-attribute>
</container-transaction>
</assembly-descriptor>
</ejb-jar>
jboss.xml
<entity>
<ejb-name>ShipBean</ejb-name>
<resource-ref>
<res-ref-name>jdbc:/mySQLDB</res-ref-name>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<res-ref-name>jdbc/mySQLDB</res-ref-name>
without the ":" -> tooo mcuh copy&paste, right??
also, bear in mind that mySQL is case sensitive!! the table Test MUST be
named Test in mySQL NOT test or TEST!!!
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
<resource-name>java:/mySQLDB</resource-name>
</resource-ref>
</entity>
