Subject: cant't read datas from database
Posted By: maxj Post Date: 8/29/2006 8:48:49 PM
hi
when I try to read data form database ,it is show wrong message :
type Exception report

message

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

exception

org.apache.jasper.JasperException: Exception in JSP: /index.jsp:65

62:&nbsp;&nbsp;&nbsp;</tr>
63:&nbsp;&nbsp;&nbsp;<%
64:&nbsp;&nbsp;&nbsp;String sql="select * from ÂÛ̳";
65:    ResultSet rs=odbc.executeQuery(sql);
66:&nbsp;&nbsp;&nbsp;while(rs.next()){
67:&nbsp;&nbsp;&nbsp;%>
68:&nbsp;&nbsp;&nbsp;<tr bgcolor="#D1EBF1">


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)

the code is:

<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>ÎÞ±êÌâÎĵµ</title>
<script language="javascript">
function re(){
form1.action="reg.jsp";
form1.method="get";
form1.submit();
}
function login(){
form1.action="loginServlet";
form1.method="post";
form1.submit();
}
</script>
<link rel="stylesheet" type="text/css" href="css/css.css">
</head>

<body>

<jsp:useBean id="odbc" scope="page" class="my.data.MyOdbc"/>
<%
String userName;
if(session.getAttribute("userId")==null){
session.setAttribute("Type","guest");
userName="ÓοÍ";
}else{
userName=(String)session.getAttribute("userId");
}

%>
<form action="loginServlet" method="post" name="form1" >
  <table width="800" align="center">
    <tr>
      <th width="573" height="24" background="pic/table.gif" scope="col">
        <div align="left">Óû§Ãû:
          <input name="userId" type="text" id="userId" size="13">
          ÃÜÂë:
          <input name="password" type="password" id="password" size="13">
          <input type="Submit" name="Submit" value="µÇ¼" onClick="login();";>
          <input type="Submit" name="Submit2" value="×¢²á" onClick="re();">
      </div></th>
      <th width="101" background="pic/table.gif" scope="col"><%if(!userName.equals("ÓοÍ")){%><a href="admin_login.jsp" >¡¾¹ÜÀí¡¿</a>
        <%}%></th>
      <th width="110" background="pic/table.gif" scope="col"><a href="loginout.jsp" >¡¾Í˳öµÇ¼¡¿</a></th>
    </tr>
  </table>
</form>
<p>&nbsp;</p>
<table width="800" border="0" align="center">
  <tr >
    <th height="24" colspan="5" background="pic/table.gif" scope="col"><marquee><%=userName%>ÄãºÃ£¡£¡»¶Ó­À´xxÂÛ̳£¡£¡<img src="pic/oicq.gif" width="16" height="16">ÄãµÄIPµØÖ·ÊÇ:<%=request.getRemoteAddr()%></marquee></th>
  </tr>
  <tr bgcolor="#EAF8FB">
    <th width="94" height="25" scope="col"> ÂÛ̳Áбí</th>
    <th width="167" scope="col"> Ìù×ÓÊýÁ¿ </th>
    <th width="167" scope="col"> ×îºó·¢±í </th>
    <th width="170" scope="col"> °æÖ÷ </th>
  </tr>
  <%
  String sql="select * from ÂÛ̳";
   ResultSet rs=odbc.executeQuery(sql);
  while(rs.next()){
  %>
  <tr bgcolor="#D1EBF1">
    <td height="38" width="94"><a href="board.jsp?boardId=<%=rs.getString("ÂÛ̳Id")%>&board=<%=rs.getString("ÂÛ̳Ãû³Æ")%>"> <%=rs.getString("ÂÛ̳Ãû³Æ")%> </a> <br />
    </td>
    <td width="167" height="38" align="center"><%=rs.getString("Ìù×ÓÊýÁ¿")%></td>
    <td width="167" height="38">ʱ¼ä£º<%=rs.getString("×îºó·¢±íʱ¼ä")%><br>
      ×÷Õߣº<%=rs.getString("×îºó·¢±íÈË")%></td>
    <td width="170" height="38" align="center"><%=rs.getString("°æÖ÷ÐÕÃû")%></td>
  </tr>
  <%
}
 odbc.closeConn();         
                %>
</table>
<jsp:include page="inc/conut.jsp" flush="true"/>
<table width="800" border="0" align="center">
  <tr>
    <td height="24" background="pic/table.gif">&nbsp;</td>
  </tr>
</table>
<p><jsp:include page="copy.jsp" flush="true" />&nbsp;</p>
</body>
</html>


and I use jdbo-odbc to connect the database .Every jsp pages want to read data from databae ,it is cant't success.
what can I do to make is wright??
thanks!

Reply By: jetbrains Reply Date: 10/2/2006 10:52:49 PM
Why not use type 4 driver?

JAVA Tutorials   Hot Web Resources

Go to topic 50283

Return to index page 158
Return to index page 157
Return to index page 156
Return to index page 155
Return to index page 154
Return to index page 153
Return to index page 152
Return to index page 151
Return to index page 150
Return to index page 149