Advertisement
Guest User

Untitled

a guest
Jul 5th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. Connection conn =null; // Create connection object
  2.  
  3.  
  4.  
  5. String database = "egertons"; // Name of database
  6.  
  7. String user = "egertons"; //
  8.  
  9. String password = "gewedonk";
  10.  
  11. String url = "jdbc:mysql://mudfoot.doc.stu.mmu.ac.uk/" + database;
  12.  
  13.  
  14.  
  15. String docType =
  16.  
  17. "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 "+
  18.  
  19. "Transitional//EN\">\n";
  20.  
  21.  
  22.  
  23. response.setContentType("text/html");
  24.  
  25. PrintWriter out = response.getWriter();
  26.  
  27. out.println(docType);
  28.  
  29.  
  30.  
  31. try{
  32.  
  33. Class.forName("com.mysql.jdbc.Driver").newInstance();
  34.  
  35. } catch(Exception e) {
  36.  
  37. System.err.println(e);
  38.  
  39. }
  40.  
  41.  
  42.  
  43. // connecting to database
  44.  
  45. try{
  46.  
  47. conn = DriverManager.getConnection(url, user, password);
  48.  
  49.  
  50.  
  51. }
  52.  
  53. catch(SQLException se) {
  54.  
  55. System.err.println(se);
  56.  
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement