MyException - 我的异常网
当前位置:我的异常网» Java Web开发 » 高分!sql语句有关问题

高分!sql语句有关问题

www.MyException.Cn  网友分享于:2013-09-12  浏览:8次
高分求助!!!sql语句问题!
jsp如下,我的javabean没问题!
<%@   page   contentType= "text/html;   charset=gb2312 "   language= "java "   import= "java.sql.* "   errorPage= " "   %>
<%@   include   file= "../include/set_china.jsp "%>
<jsp:useBean   id= "query "   class= "login.QueryBean "   scope= "page ">
</jsp:useBean>
<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html   xmlns= "http://www.w3.org/1999/xhtml ">
<head>
<link   href= "../include/css.css "   rel= "stylesheet "   type= "text/css "   />
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=gb2312 "   />
<title> 无标题文档 </title>
</head>

<body>
<%
    ResultSet   rs=null;
String   sql= "select   a.txtnumber,   a.txtname,b.course_name,b.course_mark,c.s_result   from   student_info   as   a   join   choose_course   as   c   on   a.txtnumber=c.student_id   join   course_info   as   b   on   c.s_course_id=b.course_id   where   a.txtnumber= '0467110054 ' ";
    //String   sql= "select     *   from   student_info ";
try
    {
        //设置连接
String   url= "jdbc:odbc:jwzx ";
        query.setConnection( "sun.jdbc.odbc.JdbcOdbcDriver ",url, " ", " ");
        //设置SQL语句
        query.setQuerystatement(sql);
        //得到查询结果
        rs=query.getResult();
    }
    catch(SQLException   e1)  
    {
        out.print(e1);
}
while(rs.next())
{
out.print(rs.getString(1));
out.print(rs.getString(2));
}
%>
我把数据库导入sql后select   a.txtnumber,   a.txtname,b.course_name,b.course_mark,c.s_result   from   student_info   as   a   join   choose_course   as   c   on   a.txtnumber=c.student_id   join   course_info   as   b   on   c.s_course_id=b.course_id   where   a.txtnumber= '0467110054 '此语句正确!但是在jsp中就报错!我把sql改为String   sql= "select     *   from   student_info ";后就正确!迷茫中!
错误提示:
HTTP   Status   500   -  

--------------------------------------------

type   Exception   report

message  

description   The   server   encountered   an   internal   error   ()   that   prevented   it   from   fulfilling   this   request.

exception  

org.apache.jasper.JasperException:   An   exception   occurred   processing   JSP   page   /My_jwzx/student/vew_chengji.jsp   at   line   32
29:       {
30:           out.print(e1);
31:   }
32:   while(rs.next())
33:   {
34:   out.print(rs.getString(1));
35:   out.print(rs.getString(2));

org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:555)

文章评论

软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有