Advertisement
Guest User

Untitled

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