No, I'm not sure that I'm getting the right database. However, prior to
trying to create a record, I use another method to check if the caller has
the right to create and that is done by looking up a password in another
table. As that works okay, I assume that I get the correct database also in
the ejbCreate() call.
How can I make sure?
The ejbCreate has no transaction attribute as it is a home interface
method. And the session bean doesn't do anything unusual in terms of
transactions.
Here is the database related part from jboss.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is where you can add and configure your MBeans
ATTENTION: The order of the listing here is the same order as
the MBeans are loaded. Therefore if a MBean depends on another
MBean to be loaded and started it has to be listed after all
the MBeans it depends on.
-->
<server>
<!-- Classloading -->
<mbean code="org.jboss.web.WebService"
name="DefaultDomain:service=Webserver">
<attribute name="Port">8083</attribute>
</mbean>
<!-- JNDI -->
<mbean code="org.jboss.naming.NamingService"
name="DefaultDomain:service=Naming">
<!--Cloudscape uses also port 1099.-->
<!--
<attribute name="Port">1099</attribute>
-->
<attribute name="Port">1100</attribute>
</mbean>
<mbean code="org.jboss.naming.JNDIView"
name="DefaultDomain:service=JNDIView" />
<!-- Transactions -->
<mbean code="org.jboss.tm.TransactionManagerService"
name="DefaultDomain:service=TransactionManager">
<attribute name="TransactionTimeout">300</attribute>
</mbean>
<!-- Security -->
...
<!-- JDBC -->
<mbean code="org.jboss.jdbc.JdbcProvider"
name="DefaultDomain:service=JdbcProvider">
<attribute
name="Drivers">COM.cloudscape.core.RmiJdbcDriver,org.hsql.jdbcDriver,org.en
hydra.instantdb.jdbc.idbDriver</attribute>
</mbean>
<mbean code="org.jboss.jdbc.HypersonicDatabase"
name="DefaultDomain:service=Hypersonic">
<attribute name="Port">1476</attribute>
<attribute name="Silent">true</attribute>
<attribute name="Database">default</attribute>
<attribute name="Trace">false</attribute>
</mbean>
<mbean code="org.jboss.jdbc.XADataSourceLoader"
name="DefaultDomain:service=XADataSource,name=InstantDB">
<attribute name="PoolName">InstantDB</attribute>
<attribute
name="DataSourceClass">org.opentools.minerva.jdbc.xa.wrapper.XADataSourceIm
pl</attribute>
<attribute name="Properties"></attribute>
<attribute
name="URL">jdbc:idb:../conf/default/instantdb.properties</attribute>
<attribute name="GCMinIdleTime">1200000</attribute>
<attribute name="JDBCUser" />
<attribute name="MaxSize">10</attribute>
<attribute name="Password" />
<attribute name="GCEnabled">false</attribute>
<attribute name="InvalidateOnError">false</attribute>
<attribute name="TimestampUsed">false</attribute>
<attribute name="Blocking">true</attribute>
<attribute name="GCInterval">120000</attribute>
<attribute name="IdleTimeout">1800000</attribute>
<attribute name="IdleTimeoutEnabled">false</attribute>
<attribute name="LoggingEnabled">false</attribute>
<attribute name="MaxIdleTimeoutPercent">1.0</attribute>
<attribute name="MinSize">0</attribute>
</mbean>
<mbean code="org.jboss.jdbc.XADataSourceLoader"
name="DefaultDomain:service=XADataSource,name=DefaultDS">
<attribute name="PoolName">DefaultDS</attribute>
<attribute
name="DataSourceClass">org.opentools.minerva.jdbc.xa.wrapper.XADataSourceIm
pl</attribute>
<attribute name="Properties"></attribute>
<!--
<attribute
name="URL">jdbc:HypersonicSQL:hsql://localhost:1476</attribute>
-->
<attribute
name="URL">jdbc:rmi://localhost:1099/jdbc:cloudscape:CloudscapeDB;create=tr
ue</attribute>
<attribute name="GCMinIdleTime">1200000</attribute>
<attribute name="JDBCUser">sa</attribute>
<attribute name="MaxSize">10</attribute>
<attribute name="Password" />
<attribute name="GCEnabled">false</attribute>
<attribute name="InvalidateOnError">false</attribute>
<attribute name="TimestampUsed">false</attribute>
<attribute name="Blocking">true</attribute>
<attribute name="GCInterval">120000</attribute>
<attribute name="IdleTimeout">1800000</attribute>
<attribute name="IdleTimeoutEnabled">false</attribute>
<attribute name="LoggingEnabled">false</attribute>
<attribute name="MaxIdleTimeoutPercent">1.0</attribute>
<attribute name="MinSize">0</attribute>
</mbean>
<mbean code="org.jboss.jdbc.XADataSourceLoader"
name="DefaultDomain:service=XADataSource,name=Cloudscape">
<attribute name="PoolName">Cloudscape</attribute>
<attribute
name="DataSourceClass">org.opentools.minerva.jdbc.xa.wrapper.XADataSourceIm
pl</attribute>
<attribute name="Properties"></attribute>
<attribute
name="URL">jdbc:rmi://localhost:1099/jdbc:cloudscape:CloudscapeDB;create=tr
ue</attribute>
<attribute name="GCMinIdleTime">1200000</attribute>
<attribute name="JDBCUser">sa</attribute>
<attribute name="MaxSize">10</attribute>
<attribute name="Password" />
<attribute name="GCEnabled">false</attribute>
<attribute name="InvalidateOnError">false</attribute>
<attribute name="TimestampUsed">false</attribute>
<attribute name="Blocking">true</attribute>
<attribute name="GCInterval">120000</attribute>
<attribute name="IdleTimeout">1800000</attribute>
<attribute name="IdleTimeoutEnabled">false</attribute>
<attribute name="LoggingEnabled">false</attribute>
<attribute name="MaxIdleTimeoutPercent">1.0</attribute>
<attribute name="MinSize">0</attribute>
</mbean>
I'm definitely not yet on top of the resource manager issue.
Ralph
----- Original Message -----
From: Burkhard Vogel <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 10, 2001 3:44 PM
Subject: Re: [JBoss-user] BMP entity bean, commit problems
> Hi,
> Are you sure you are getting the right Database, sometimes DefaultDS is
> picked up instead of the DB wanted.
> What kind of transaction attribute have you assigned to your method?
> Burkhard
>
> ----- Original Message -----
> From: "ralph" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, July 10, 2001 8:14 AM
> Subject: [JBoss-user] BMP entity bean, commit problems
>
>
> > I search the messages, but didn't find the answer here. Don't have the
> same
> > problem with Sun's J2EE reference platform.
> >
> > From a session bean I use an entity bean to create a database record. I
> > wrote a short program which creates one record. After the program ends,
I
> > don't find the record by directly accessing the database ( SELECT *
FROM
> > ... ). However, when the program is run twice, it correctly refuses
> > creation at the second time, because the primary key is not unique.
> >
> > I tried commit option A and B, though that shouldn't be the problem.
> > I close the PreparedStatement and the database connection after the
call.
> >
> >
> > This is the related code:
> >
> > public void setEntityContext(EntityContext context)
> > throws javax.ejb.EJBException, java.rmi.RemoteException {
> >
> > m_context = context;
> >
> > try {
> > InitialContext initial = new InitialContext();
> > m_ds = (DataSource) initial.lookup( dbName );
> > } catch( NamingException xn ) {
> > m_ds = null;
> > }
> > }
> >
> > private void makeConnection() throws SQLException {
> > m_con = m_ds.getConnection();
> > }
> >
> >
> > private void closeConnection(){
> > System.out.println( "CB.closeConnection()" );
> > if ( m_con != null ){
> > try {
> > m_con.close();
> > } catch( Exception x ){ m_con = null; }
> > }
> > }
> >
> >
> > public String ejbCreate( ConferenceData cd ) throws CreateException {
> >
> > try {
> > makeConnection();
> > insertRow( cd.topic, cd.id, .... );
> > } catch( Exception x ) {
> > throw new EJBException( "ConfB.ejbCreate(CD): " + x );
> > }
> > finally {
> > closeConnection();
> > }
> >
> > id = cd.id; // pk
> > topic = cd.topic;
> > ....
> > return id;
> > }
> >
> >
> > private void insertRow( String topic, String id, .... ) throws
> SQLException
> > {
> >
> > System.out.println( "CB.insertRow() - enter" );
> >
> > PreparedStatement pstmt = null;
> > String insertStatement =
> > "INSERT INTO conference( topic, id, startTimeS, duration, "
+
> > "moderator, modPasswd, modGroupPasswd, generalPasswd, " +
> > "hasWhiteboard, hasSlideScreen, hasTextChat, hasVoiceChat, "
+
> > "status, type, creatorID, createTime, billingID ) " +
> > "VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )";
> >
> > try {
> > pstmt = m_con.prepareStatement( insertStatement );
> >
> > pstmt.setString( 1, topic );
> > pstmt.setString( 2, id );
> > ....
> >
> > pstmt.executeUpdate();
> > } catch( SQLException xs ){
> > throw new SQLException( "CB.insertRow(): " + xs );
> > }
> > finally {
> > if ( pstmt != null ) {
> > try {
> > pstmt.close();
> > } catch( Exception x ) { pstmt = null; }
> > }
> > }
> > }
> >
> >
> >
> >
> >
> > _______________________________________________
> > JBoss-user mailing list
> > [EMAIL PROTECTED]
> > http://lists.sourceforge.net/lists/listinfo/jboss-user
>
>
> _______________________________________________
> JBoss-user mailing list
> [EMAIL PROTECTED]
> http://lists.sourceforge.net/lists/listinfo/jboss-user
_______________________________________________
JBoss-user mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/jboss-user