Hi.

Please stop posting enormous HTML messages.

Have you tried this test without setting autoCommit? What is the
transaction attribute of the session bean method?

Regards,
Toby.

> "Bolt, Dave" wrote:
> 
> As you know, I've been having trouble with container managed
> transactions and Oracle. I thought I would try the following code.
> 
> In essence, it gets a connection from the pool, does an insert, throws
> away the connection, then gets another connection and
> 
> tries the second insert. This exhibits the same problem that I'm
> having with my session beans and entity beans where the connections
> 
> are separate and the insert into the document_version table fails
> because it is waiting on the row in the product table.
> 
> Should I avoid Foreign Keys wherever my entity beans have
> relationships?
> 
> Any Ideas?
> 
> This code is in a business method of a stateless session bean
> (ddc/DocumentLoader). I invoke it from a servlet.
> 
>         try
>         {
>             Context context = new InitialContext();
>             DataSource ds =
> (DataSource)context.lookup(JNDINames.DB_POOL);
>             Connection con = ds.getConnection();
>             con.setAutoCommit(false);
>             String sql = "INSERT INTO product ( product_type_cd,
> school_cd, product_id, tng_mat_production_dt, security_class_cd,
> product_nm,    product_proponent_cd,    proponent_person_id,
> product_status_cd,    distribution_restriction_cd,
> distribution_restriction_tx )    VALUES ( 'FM',    '1',    'FM
> 1-1',    ?, 'U', 'Test', 1, 'boltd', 'A', 'A', 'Public Distribution'
> )";
> 
>             PreparedStatement stmt = con.prepareStatement(sql);
>             stmt.setDate(1,Conversion.toSQLDate("01/01/2001"));
>             stmt.executeUpdate();
>             stmt.close();
>             con.close();
>             ds = null;
>             con = null;
> 
>             ds = (DataSource)context.lookup(JNDINames.DB_POOL);
>             con = ds.getConnection();
> 
>             sql = "INSERT INTO document_version (
> product_id,document_version_id,    product_status_cd,
> version_creation_dt,    web_publish_cd,    document_version_nm )
> VALUES ( 'FM 1-1',    1,    'P',    ?,    'N',    'Test' )";
> 
>             stmt = con.prepareStatement(sql);
>             stmt.setDate(1,Conversion.toSQLDate("01/01/2001"));
> 
>                 // This insert will fail, due to the FK relationship
> between product and document_version.
>             stmt.executeUpdate();
>             stmt.close();
>             con.close();
>         }
>         catch (SQLException e)
>         {
>             System.out.println(e.getMessage());
>             e.printStackTrace();
>             throw new EJBException("Could not lookup Product");
>         }
>         catch (NamingException ne)
>         {
>             System.out.println(ne);
>             throw new EJBException("Could not lookup Product");
>         }
>         catch (Exception ne)
>         {
>             System.out.println(ne);
>             throw new EJBException("Could not lookup Product");
>         }


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]

Reply via email to