Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. public List<Application> getAllapplicationDetails(String name)
  2. {
  3. List<Application> app=new ArrayList<Application>();
  4. try
  5. {
  6.  
  7. Connection con = null;
  8.  
  9. String dbUrl = "jdbc:oracle:thin:@localhost:1521:XE";
  10. System.out.println("1 step");
  11. Class.forName("oracle.jdbc.driver.OracleDriver");
  12. System.out.println("2 step");
  13. con = DriverManager.getConnection (dbUrl, "system", "system");
  14. System.out.println("3 step");
  15. PreparedStatement ps = con.prepareStatement("select * from Application where LOWER(name) like '"+ name.toLowerCase()+"%'");
  16. System.out.println("Entering in to the fucntion 2");
  17. ps.execute();
  18. System.out.println("Entering in to the fucntion 13");
  19. ResultSet rs =ps.getResultSet();
  20. if(rs.next())
  21. {
  22. System.out.println("Entering in to the fucntion 4");
  23. Application abean=new Application();
  24. abean.setName(rs.getString(1));
  25. abean.setApplicationName(rs.getString(2));
  26. abean.setContactNumber(rs.getInt(3));
  27. app.add(abean);
  28. System.out.println("Entering in to the fucntion 1" + app);
  29. }
  30. }
  31. catch(SQLException e)
  32. {
  33. e.printStackTrace();
  34. } catch (ClassNotFoundException e) {
  35. // TODO Auto-generated catch block
  36. e.printStackTrace();
  37. }
  38. return app;
  39.  
  40. hs.setAttribute("detbean",dbean);
  41. if(dbean.isEmpty())
  42. {
  43. response.setContentType("text/html");
  44. PrintWriter out = response.getWriter();
  45. out.print("<caption>Sorry, No Record Found</caption>");
  46. }
  47. else
  48. response.sendRedirect("Application.jsp");
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement