-
1. Re: Can i use CachedRowSet in EntityBean
l.g. Jan 28, 2002 3:22 PM (in response to ipozeng)There is a pattern on theserverside.com.
You need to become a member (it`s free):
http://www.theserverside.com/resources/review/ejbpatterns-datatransferrowset-sept3.zip -
2. Re: Can i use CachedRowSet in EntityBean
ipozeng Jan 29, 2002 3:06 AM (in response to ipozeng)Thanks for the information you supplied! i will study it as soon as possible.
Best Regards! -
3. Re: Can i use CachedRowSet in EntityBean
ipozeng Feb 25, 2002 10:08 PM (in response to ipozeng)I donot know why the CachedRowSet doesnot support CMT :(
.....
When executing acceptChanges() it always reports
"javax.transaction.TransactionRolledbackException: Cannot commit a transactional connection: See JDBC 2.0 Optional Package Specification section 7.1 (p25)" !
i guess it called commit in acceptChanges() !
Can i get its source code?
Best Regards! -
4. Re: Can i use CachedRowSet in EntityBean
taiwubrian Feb 28, 2002 11:11 AM (in response to ipozeng)I read the JavaDoc about CachedRowSet. As it describes, CachedRowSet can be used with any data source. You can populate data frim within an EJB CMP entity or session bean.
Thanks for the info. I actually am using Collections and value objects to cache row sets. I can use any source of data. So far works for me. However, I would like to try a "standard" one. -
5. Re: Can i use CachedRowSet in EntityBean
ipozeng Feb 28, 2002 7:45 PM (in response to ipozeng)Now i really know why the CachedRowSet cannot be used in CMT bean by using jad tool.The following is code snippet produced by jad:
...
public boolean writeData(RowSetInternal rowsetinternal)
throws SQLException
{
boolean flag = false;
boolean flag1 = false;
PreparedStatement preparedstatement = null;
CachedRowSet cachedrowset = (CachedRowSet)rowsetinternal;
con = ((RowSetReaderImpl)cachedrowset.getReader()).connect(rowsetinternal);
if(con == null)
throw new SQLException("Unable to get Connection");
if(con.getAutoCommit())
con.setAutoCommit(false);
con.setTransactionIsolation(cachedrowset.getTransactionIsolation());
initSQLStatements(cachedrowset);
preparedstatement = con.prepareStatement(insertCmd);
if(callerColumnCount < 1)
{
if(((RowSetReaderImpl)cachedrowset.getReader()).getCloseConnection())
con.close();
return true;
}
flag1 = cachedrowset.getShowDeleted();
cachedrowset.setShowDeleted(true);
cachedrowset.beforeFirst();
while(cachedrowset.next())
if((!cachedrowset.rowDeleted() || !cachedrowset.rowInserted()) &&
(cachedrowset.rowDeleted() ? (flag = deleteOriginalRow(cachedrowset)) :
cachedrowset.rowInserted() ?
(flag = insertNewRow(cachedrowset, preparedstatement)) :
cachedrowset.rowUpdated() && (flag = updateOriginalRow(cachedrowset))))
break;
preparedstatement.close();
cachedrowset.setShowDeleted(flag1);
if(flag)
{
con.rollback(); <----- donot allowed using CMT
if(((RowSetReaderImpl)cachedrowset.getReader()).getCloseConnection())
con.close();
return false;
}
con.commit(); <----- donot allowed using CMT
if(((RowSetReaderImpl)cachedrowset.getReader()).getCloseConnection())
con.close();
return true;
}
....
By comment the commit and rollback call it works great when using CMT :)
jad is a wonderful tool however i am uncomfortable because i feel it is so easy to decompile class file :(
Moreover since sun doesnot prevent it from decompiling by obfuscating it why doesnot sun make it open source ?
BTW,when compiling the jad output you must make jboss-jdbc_ext.jar,xerces.jar be in classpath.For me i still cannot compile WebRowSet.java and Xml*.java as i cannot find out which jar file contains com.sun.xml.parser.* classes.