Advertisement
Guest User

Untitled

a guest
Oct 30th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  2. pageEncoding="ISO-8859-1"%>
  3. <%@ page import="java.sql.*" %>
  4. <%@ page import="java.io.*" %>
  5. <html>
  6. <head>
  7. <title>Connection with mysql database</title>
  8. </head>
  9. <body>
  10. <h1>Connection status</h1>
  11. <%
  12. try {
  13. String connectionURL = "jdbc:mysql://localhost/soen";
  14. Connection connection = null;
  15. Class.forName("com.mysql.jdbc.Driver").newInstance();
  16. connection = DriverManager.getConnection(connectionURL, "root","");
  17. if(!connection.isClosed())
  18. out.println("Successfully connected to " + "MySQL server using TCP/IP...");
  19. connection.close();
  20. }catch(Exception ex){
  21. out.println("Unable to connect to database.");
  22. out.println(ex);
  23. }
  24. %>
  25. </font>
  26. </body>
  27. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement