URL problem in mysql connection in jsp
Hello All,
I am writing code for mysql connection using IP address with JSP. It is not connecting to mysql. can any one tell me solution for this:-(
Thanks in advance
Rashmi
below is the jsp file
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page language="java" import="java.sql.*;" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<% Connection con = null;
ResultSet rs = null;
Statement st = null;
try {
String dbuser = "root";
String dbpass = "admin";
String url = "jdbc:mysql://192.168.0.13/mysql";
Class.forName("com.mysql.jdbc.Driver").newInstance ();
con = DriverManager.getConnection(url, dbuser, dbpass);
st = con.createStatement();
out.println("database connection esablished");
}
catch(SQLException e)
{
out.println("can not connect to database");
}
finally
{
}
%>
</body>
</html>