Skip navigation links

MySQL Forums :: JDBC and Java :: jsp connection with mysql


Advanced Search

jsp connection with mysql
Posted by: ()
Date: November 02, 2009 12:12PM

<%
Connection c;
Statement s;
ResultSet rs;

try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c=DriverManager.getConnection("jdbc:odbc:blood1");
s=c.createStatement();
if (request.getParameter("uid").equals(null) || request.getParameter("uid").equals(""))
{
out.println("Error Invalid value <h3> Press browser BACK button to correct entries</h3>");
}
else
{
rs=s.executeQuery("select user_id,password from info where user_id="+request.getParameter("uid")+"and password='"+request.getParameter("pwd")+"'");
if(rs.next())
{
//out.println("user id and password match");
session.setAttribute("userid",request.getParameter("uid"));
response.sendRedirect("welcome1.jsp");
}
else
{
//out.println("user id and password dont match");
response.sendRedirect("Donor_login.jsp");
}
}
}catch(Exception e) {out.println(e);}
%>


For the above code it is showing error given below.
My connection n all is working fine . Please help me with the sql syntax.

java.sql.SQLException: [MySQL][ODBC 5.1 Driver][mysqld-5.1.39-community]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'password='1234'' at line 1

Options: ReplyQuote


Subject Written By Posted
jsp connection with mysql 11/02/2009 12:12PM
Re: jsp connection with mysql Andrew Priebe 11/06/2009 06:54AM


Sorry, only registered users may post in this forum.