Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement