SHARE
TWEET

Untitled

a guest Feb 19th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public boolean deleteStudent(String [] ids) {
  2.  
  3.             Connection connection = null;
  4.             String query;
  5.             boolean result = false;
  6.  
  7.             try {
  8.                 Context initCtx = new InitialContext();
  9.                 Context envCtx = (Context) initCtx.lookup("java:comp/env");
  10.                 DataSource ds = (DataSource) envCtx.lookup("jdbc/cmsDB");
  11.                 connection = ds.getConnection();
  12.  
  13.                 QueryRunner run = new QueryRunner(ds);
  14.                 query = "delete tbl_student where student_id";// what should i put here???
  15.                 int nor = run.update(query, ids); //nor = no of records
  16.  
  17.                 if (nor > 0) {
  18.                     result = true;
  19.                 } else {
  20.                     result = false;
  21.                 }
  22.             } catch (NumberFormatException e) {
  23.                 // e.getMessage();
  24.                 e.printStackTrace();
  25.             } catch (SQLException e) {
  26.                 e.printStackTrace();
  27.             } catch (Exception e) {
  28.                 e.printStackTrace();
  29.             } finally {
  30.                 DbUtils.closeQuietly(connection);
  31.             }
  32.             return result;
  33.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top