• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

CachedRowSet.acceptChanges();

 
jonathan Greens
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • 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;
}
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic