Advertisement
Guest User

Untitled

a guest
Sep 27th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6. package Connections;
  7.  
  8.  
  9.  
  10. import java.io.IOException;
  11. import java.sql.Connection;
  12. import java.sql.DriverManager;
  13. import java.sql.SQLException;
  14.  
  15. public class WebConn
  16. {
  17. public Connection getConnect()throws SQLException,IOException
  18. {
  19. try
  20. {
  21. Class.forName("com.mysql.jdbc.Driver").newInstance();
  22. System.out.println("I am in WebConnectin class");
  23. Connection con=DriverManager.getConnection("jdbc:mysql://192.168.2.8:3306/training","trainee","trainee");
  24. System.out.println("connection Sucessfully Created web conn class"+con);
  25. return con;
  26. }
  27.  
  28. catch(Exception ex)
  29. {
  30. ex.printStackTrace();
  31. return (Connection)null;
  32. }
  33. }
  34. public boolean closeConnection(Connection con)
  35. {
  36. try
  37. {
  38. con=null;
  39. }
  40. catch (Exception ex)
  41. {
  42.  
  43. }
  44. return true;
  45. }
  46.  
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement