Advertisement
Guest User

Untitled

a guest
Dec 29th, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. Guard g;
  2.  
  3. public Connection dajSpojenie(HttpServletRequest request) {
  4. try {
  5. HttpSession session = request.getSession();
  6. if(session.getAttribute("spojenie")==null){
  7. Class.forName("com.mysql.jdbc.Driver");
  8. Connection c = DriverManager.getConnection("jdbc:mysql://localhost/shop", "root", "");
  9. g = new Guard(c);
  10.  
  11.  
  12. return c;
  13. }else{
  14. return (Connection)session.getAttribute("spojenie");
  15. }
  16. }catch(Exception e){
  17. return null;
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement