Advertisement
Guest User

Untitled

a guest
Oct 31st, 2017
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
J 0.56 KB | None | 0 0
  1. <%@ page import="java.sql.*"%>
  2. <html>
  3. <head>
  4. <title>JDBC Connection example</title>
  5. </head>
  6.  
  7. <body>
  8. <h1>JDBC Connection example</h1>
  9.  
  10. <%
  11.   String db = "soen";
  12.   String user = "root";
  13.   String password = "";
  14.   try {
  15.     java.sql.Connection con;
  16.     Class.forName("org.gjt.mm.mysql.Driver");
  17.     con = DriverManager.getConnection("jdbc:mysql://localhost/"+db, user, password);
  18.     out.println (db+ ": database successfully opened.");
  19.   }
  20.   catch(SQLException e) {
  21.     out.println("SQLException caught: " +e.getMessage());
  22.   }
  23. %>
  24.  
  25. </body>
  26. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement