Advertisement
Guest User

Untitled

a guest
Mar 10th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
  2.  
  3. Connection con = connect();
  4. ...
  5. }
  6.  
  7. private Connection connect() {
  8. try {
  9. Class.forName("com.mysql.jdbc.Driver");
  10. return DriverManager.getConnection("jdbc:mysql://localhost:3306/chat", "serveradmin", "password");
  11. } catch (Exception e) {
  12. System.out.println("Failed to obtain connection: " + e);
  13. System.out.println(e.getStackTrace());
  14. return null;
  15. }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement