Hi,
I am new to mysql connectivity using jsp. but i have tried it with MS Access nd it worked out for me.
I have installed jdk1.4, Tomcat5.0, mysql 4.1 and mysql_connector_odbc_3.51.21_win32.msi. For the following code i am getting error code 500..
I have set the Env paths as
path %SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Common Files\Adaptec Shared\System;C:\Program Files\Java\jdk1.5\bin;C:\Program Files\Java\jdk1.5\jre\lib\rt.jar;C:\Program Files\Java\jdk1.5\common\lib\servlet-api.jar;C:\Program Files\Apache Software Foundation\Tomcat 5.0\bin;C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar;C:\Program Files\MySQL\MySQL Server 4.1\bin;C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\Mysql\WEB-INF\lib\mysql-connector-java-3.0.15-ga-bin.jar;
Where Mysqls folder containing files in webapps,
Can u Plz tel me how to solve it. As per i found its error in Driver.Manager statement.
<html>
<head><br><br>
<center>Data retreived from data base(If Retreives)</center><br><hr><br><br>
</head>
<body>
<%@ page language="java" import="java.sql.*, java.io.*" %>
<%
String userName = null;
String Password = null;
userName = request.getParameter("user");
Password = request.getParameter("pswd");
Connection con = null;
try {
Class.forName("org.gjt.mm.mysql.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/Rajesh","root","mysql");
Statement statement = con.createStatement();
ResultSet rs = statement.executeQuery("SELECT * FROM prim WHERE name = '"+userName+"'");
while ( rs.next() ) {
%>
<p><h1>Welcome <%= userName %>!</h1></p>
<p>Your no is: <%= rs.getString("no") %></p>
<p>Your setno no.is: <%= rs.getString("setno") %></p>
<%
}
rs.close();
//System.in.read();
}
catch (IOException ioe) {
System.err.println(ioe.getMessage());
ioe.printStackTrace();
}
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
sqle.printStackTrace();
}
catch (ClassNotFoundException cnfe) {
System.err.println(cnfe.getMessage());
cnfe.printStackTrace();
}
catch (Exception e) {
System.err.println(e.getMessage());
e.printStackTrace();
}
finally {
try {
if ( con != null ) {
con.close();
}
}
catch (SQLException sqle) {
System.err.println(sqle.getMessage());
}
}
%>
</body>
</html>
Plz give solution for my problem........