Skip to main content

java.sql.SQLException: General error

1 reply [Last post]
rahulrajcse
Offline
Joined: 2011-04-15
Points: 0

what is the cause of java.sql.SQLException: General error?
my code is given below: (jsp code)
<%
String usn = request.getParameter("username1");
String pass = request.getParameter("password1");

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:rahul";
Connection con = DriverManager.getConnection(url);
Statement s = con.createStatement();

ResultSet rs = s.executeQuery("select * from customers");
while(rs.next())
{
String u = rs.getString("username");
String p = rs.getString("password");
if(usn.equals(u) && pass.equals(p))
{
out.println("login successfull");
}
else
{
out.println("login failed");
}
}
}

catch(NullPointerException e)
{
out.println("null pointer exception");
}

catch(Exception e)
{
out.println("Error"+e);
}

%>

This is just a sample code, and I know this is not perfect. But, pls help me to resolve this problem..

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
slash13
Offline
Joined: 2011-06-04
Points: 0

Hey

I suggest you to use SQLException instead of Exception to catch the Exception and use the e.getMessage() and e.getStackTrace() to see where is your problem, generally a SQLException is because a problem with the connection or with the statements