Hi,friends
I have developed multi-tier application using delphi for many years.The class "TClientDataSet" is my favorite ! She not only provides standard transportable data packet format,but also providing a unique way to operate data set.
After entering J2EE domain,i cannot find a similar way !The "Colloection" class doesnot provide uniform interface for the client side because the elements he contains may be very defferent! It is too complicate !
Recently i downloaded the rowset class library from sun website.And i feel the classes in rowset are very similar with "TClientDataSet"(maybe the rowset is developed by borland )
The following is some code snippet:
...
public class CoffeesBean implements SessionBean
{
...
private Connection getConnection() throws Exception
{
InitialContext initCtx = null;
initCtx = new InitialContext();
ds = (javax.sql.DataSource) initCtx.lookup("java:/SQLServerPool"
initCtx.close();
return ds.getConnection();
}
public RowSet getCoffees() throws SQLException
{
Connection con = null;
PreparedStatement stmt = null;
CachedRowSet crs = null;
ResultSet rs;
try {
con = getConnection();
stmt = con.prepareStatement("select * from coffees"
rs = stmt.executeQuery();
crs = new CachedRowSet();
crs.populate(rs);
// the writer needs this because JDBC drivers
// don't provide this meta-data.
crs.setTableName("coffees"
rs.close();
stmt.close();
}catch(Exception e) {
} finally {
if (con != null)
con.close();
}
return crs;
}
public void updateCoffees(RowSet rs) throws SQLException
{
Connection con = null;
try {
CachedRowSet crs = (CachedRowSet)rs;
con = getConnection();
// moves the changes back to the database
crs.acceptChanges(con);
}catch(Exception e) {
}
finally {
if (con != null)
con.close();
}
}
...
}
Isnot it simple?
At present the rowset is not a part of java extended class library however i believe she will succeed in the future!
What is your suggestion and comment?
Best Regards!
IPO_z@cmmail.com
Garbage in,Garbage out
I have developed multi-tier application using delphi for many years.The class "TClientDataSet" is my favorite ! She not only provides standard transportable data packet format,but also providing a unique way to operate data set.
After entering J2EE domain,i cannot find a similar way !The "Colloection" class doesnot provide uniform interface for the client side because the elements he contains may be very defferent! It is too complicate !
Recently i downloaded the rowset class library from sun website.And i feel the classes in rowset are very similar with "TClientDataSet"(maybe the rowset is developed by borland )
The following is some code snippet:
...
public class CoffeesBean implements SessionBean
{
...
private Connection getConnection() throws Exception
{
InitialContext initCtx = null;
initCtx = new InitialContext();
ds = (javax.sql.DataSource) initCtx.lookup("java:/SQLServerPool"
initCtx.close();
return ds.getConnection();
}
public RowSet getCoffees() throws SQLException
{
Connection con = null;
PreparedStatement stmt = null;
CachedRowSet crs = null;
ResultSet rs;
try {
con = getConnection();
stmt = con.prepareStatement("select * from coffees"
rs = stmt.executeQuery();
crs = new CachedRowSet();
crs.populate(rs);
// the writer needs this because JDBC drivers
// don't provide this meta-data.
crs.setTableName("coffees"
rs.close();
stmt.close();
}catch(Exception e) {
} finally {
if (con != null)
con.close();
}
return crs;
}
public void updateCoffees(RowSet rs) throws SQLException
{
Connection con = null;
try {
CachedRowSet crs = (CachedRowSet)rs;
con = getConnection();
// moves the changes back to the database
crs.acceptChanges(con);
}catch(Exception e) {
}
finally {
if (con != null)
con.close();
}
}
...
}
Isnot it simple?
At present the rowset is not a part of java extended class library however i believe she will succeed in the future!
What is your suggestion and comment?
Best Regards!
IPO_z@cmmail.com
Garbage in,Garbage out