As I am new to MySQL, I dont know how to connect my jsp page to the MySQL Database.
So please help me by giving some code on how to connect.
I have downloaded driver for Java named as Connector/J.
MySQL version is 5.0.
In this line
con = DriverManager.getConnection("jdbc:mysql://localhost/JSP_MYSQL?user=root&password=admin");
what is wrong where i have to give MySQL username and password and the name of the Database.
So please help me out.
It's Urgent.
Thanks..
<%!
Connection con = null;
Statement state = null;
ResultSet rs = null;
%>
<%
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
con = DriverManager.getConnection("jdbc:mysql://localhost/JSP_MYSQL?user=root&password=admin");
state = con.createStatement();
String s = "Select * from user.login";
rs = state.executeQuery(s);
}
catch(SQLException e)
{
e.printStackTrace();
}
%>