Hi,

I've recently started learning EJBs and have been having a few
problems getting a BMP entity bean to work.

PROBLEM ONE:
The code to create a database entry is in the ejbCreate method where
I  create a statement with the string "INSERT INTO product (id, name)
VALUES (123, 'Test')"

On running this method, an entry is added to the database, but a
SQLException is still thrown.  The exception is [TDS Driver] No
result sets were produced by 'INSERT INTO....'

Can someone explain why this error is occuring and what I should do
to fix it?  I've fixed it using stored procedures, but I would still like to
know how to use INSERT INTO if needed in the future.

PROBLEM TWO
Also, in my test client I've got 2 calls to home.create followed by one call
to home.findByPrimaryKey.  The calls to create work fine, but the third call
fails with a SQLException:  too many connections: 3

Again, I dont understand why there are too many connections.  Where would
this setting be (Jrun, SQLServer or the JDBC Driver!).  I am closing the
connections in the finally clause of the create methods, so those two
connections should have been released back into the connection pool.  Any
suggestions on why and how of this problem.  I am using Jrun 3.0 Developer
edition with SQL Server 2000 running on Win2000.  The JDBC drivers are
provided by Opta2000.

Now for some other questions that have been bugging me.

1)  The docs say that ejbCreate is to validate and prepare all the
data for creation into the database and the ejbPostCreate does the
actual insertion.  ejbCreate returns an object with type primary key.
 However, in my case, the primary key is created by the database, so
I dont know the primary key value till it is actually a record is
actually created.  hence, I have the insertion code in the ejbCreate
method itself and have left the ejbPostCreate method empty.

2)  The updating of the database record with every ejbStore seems
inefficient if the data does not change.  What can I need to do so
that only when the data changes, a connection is made to the database.

Thanks
Vivek




~~~~~~~~~~~~~ Paid Sponsorship ~~~~~~~~~~~~~
Get Your Own Dedicated Win2K Server!      Instant Activation for $99/month w/Free 
Setup from SoloServer      PIII600 / 128 MB RAM / 20 GB HD / 24/7/365 Tech Support     
 Visit SoloServer, https://secure.irides.com/clientsetup.cfm.
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to