• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

CachedRowSet.acceptChanges();

 
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
when I invoke CachedRowSet.acceptChanges() without a Connection as a parameter, it returns the following exception:
ava.sql.SQLException: Unable to get connection
I constructed the CachedRowSet from the ResultSet , the complete code is as follows:
any idea why? the acceptChanges(Connection) does work though.
thanks!!

public CachedRowSet executeQueryWithParams(String s, Object[]params) throws SQLException{
CachedRowSet rowset=null;

PreparedStatement st;
Connection con=getConnection();
try {
st = con.prepareStatement(s);

for(int i=0;i<params.length;i++){
if(params[i]==null){
st.setNull(i+1,java.sql.Types.NULL);
}
else if(params[i] instanceof String){

st.setString(i+1,(String)params[i]);
}
else if(params[i] instanceof Integer){
st.setInt(i+1,((Integer)params[i]).intValue());
}

}
ResultSet rs=st.executeQuery();
rowset=new CachedRowSetImpl();
rowset.populate(rs);

}
finally{
closeConn();
}
return rowset;
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic