日期:2014-05-18  浏览次数:20724 次

运行jsp页面抛出异常,不知道哪出问题了~
org.apache.jasper.JasperException:   Exception   in   JSP:   /login.jsp:15

12:       String   pr=(String)request.getAttribute( "password ");
13:       String   sql= "select   *   from   USERTEST   where   UNAME   = ' "+ur+ " '   and   UPASS   = ' "+pr+ " ' ";
14:       ResultSet   rs=null;
15:       rs=jdbc.query(sql);
16:       if(rs.next())
17:       {session.setAttribute( "username ",ur);}
18:       else


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root   cause  


------解决方案--------------------
编译都没有通过啊,是不是else后面的括号不匹配?jdbc这个对象引入了没有?
------解决方案--------------------
需要把代码全部贴上来,否则根本没办法看。
------解决方案--------------------
rs=jdbc.query(sql);这而有问题,没结果为空指针。用try(){}catch(){}试试或检查你的bean方法。

------解决方案--------------------
type Exception report//

看看你数据库中的 UR类型和你定义的类型是不是一样的,给分
------解决方案--------------------
同上
下面做补充

1、Oracle8/8i/9i数据库(thin模式)
Class.forName( "oracle.jdbc.driver.OracleDriver ").newInstance();
String url= "jdbc:oracle:thin:@localhost:1521:orcl "; //orcl为数据库的SID
String user= "scott ";
String password= "tiger ";
Connection conn= DriverManager.getConnection(url,user,password);


  2、DB2数据库
Class.forName( "com.ibm.db2.jdbc.app.DB2Driver ").newInstance();
String url= "jdbc:db2://localhost:5000/sample "; //sample为你的数据库名
String user= "admin ";
String password= " ";
Connection conn= DriverManager.getConnection(url,user,password);


  3、Sql Server7.0/2000数据库
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();
String url= "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb ";
//mydb为数据库
String user= "sa ";
String password= " ";
Connection conn= DriverManager.getConnection(url,user,password);


  4、Sybase数据库
Class.forName( "com.sybase.jdbc.SybDriver ").newInstance();
String url = " jdbc:sybase:Tds:localhost:5007/myDB ";//myDB为你的数据库名
Properties sysProps = System.getProperties();
SysProps.put( "user ", "userid ");
SysProps.put( "password ", "user_password ");
Connection conn= DriverManager.getConnection(url, SysProps);

5、Informix数据库
Class.forName( "com.informix.jdbc.IfxDriver ").newInstance();
String url = "jdbc:informix-sqli://123.45.67.89:1533/myDB:INFORMIXSERVER=myserver;
user=testuser;password=testpassword "; //myDB为数据库名
Connection conn= DriverManager.getConnection(url);