Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ page import="java.sql.*" %>
- <%@ page import="java.io.*" %>
- <html>
- <head>
- <title>Connection with mysql database</title>
- </head>
- <body>
- <h1>Connection status</h1>
- <%
- try {
- String connectionURL = "jdbc:mysql://localhost/?user=root";
- Connection connection = null;
- Class.forName("com.mysql.jdbc.Driver").newInstance();
- connection = DriverManager.getConnection(connectionURL, "username", "password");
- if(!connection.isClosed())
- out.println("Successfully connected to " + "MySQL server using TCP/IP...");
- connection.close();
- }catch(Exception ex){
- out.println("Unable to connect to database"+ex);
- }
- %>
- </font>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement