> 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.
I'm guessing you might be using executeQuery() instead of executeUpdate() or
execute() for the insert.
> 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.
Well I'm no expert at this but I guess you need to have the insert in the
ejbCreate, and select the primary key back out after. The JRun docs seem to
take a different attitude than Sun's EJB specs regarding what should be in
the ejbCreate and what should be in the ejbPostCreate... I don't see any
reason not to put the insert SQL into the ejbCreate, this seems to be what
the spec recommends. One difference is that in ejbPostCreate you can do
getEJBObject and getPrimaryKey on the EntityContext.
Note that JRun seems to require an ejbPostCreate method to be defined in
your ejb, I don't know why.
> 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.
With BMP you are the one doing the write to the database (via ejbStore), so
you can keep a flag yourself. with CMP look at InstanceManager.setDirty(),
but I've never tried it.
Paul
~~~~~~~~~~~~~ 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