public int deleteRows(String tableName) throws NamingException, SQLException {
  Context ctx=cache.getJNDIContext();
  DataSource da=(DataSource)ctx.lookup("java:/SimpleDataSource");
  Connection conn=da.getConnection();
  Statement stmt=conn.createStatement();
  int rowsDeleted=0;
  String sql="";
  sql="select * from " + tableName;
  ResultSet rs=stmt.executeQuery(sql);
  if (rs.next()) {
    sql="delete from  " + tableName;
    rowsDeleted=stmt.executeUpdate(sql);
  }
  rs.close();
  stmt.close();
  conn.close();
  return rowsDeleted;
}

public int deleteRows ( String tableName ) throws NamingException , SQLException { Context ctx = cache . getJNDIContext ( ) ; DataSource da = ( DataSource ) ctx . lookup ( "java:/SimpleDataSource" ) ; Connection conn = da . getConnection ( ) ; Statement stmt = conn . createStatement ( ) ; int rowsDeleted = 0 ; String sql = "" ; sql = "select * from " + tableName ; ResultSet rs = stmt . executeQuery ( sql ) ; if ( rs . next ( ) ) { sql = "delete from  " + tableName ; rowsDeleted = stmt . executeUpdate ( sql ) ; } rs . close ( ) ; stmt . close ( ) ; conn . close ( ) ; return rowsDeleted ; }
this method is used to delete all rows from the timestamped table created by createtable ( ) in cacheutils class .
