Hi all,
I'm setting MySQL query result after serializing the result set. It is time
consuming and I'm not getting expected results. Below is the code I'm
using. Is there any better methods?
query is the hashed value of original MySQL query - query1
if (mcc.get(query) != null)
{
CachedRowSetImpl ccRs = (CachedRowSetImpl)mcc.get(query);
System.out.println("Data found");
try{
ccRs.beforeFirst();
}catch(Exception e){};
try{
while (ccRs.next()){
//printing result
}
}catch(Exception e){};
else
{
System.out.println("Data not found");
try{
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, user, password);
System.out.println ("Database connection established");
s = conn.createStatement();
s.executeQuery(query1);
rs = s.executeQuery(query1);
CachedRowSetImpl crs=new CachedRowSetImpl();
crs.populate(rs);
mcc.set(query,crs,new Date (5*60000)); //5 minutes
CachedRowSetImpl ccRs = (CachedRowSetImpl)mcc.get(query);
ccRs.beforeFirst();
while (ccRs.next()){
//printing result
}
}catch(Exception e){}
System.out.println("The data written");
}
--
Regards,
Randeep