Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > JSP Basics
|
JSP Basics Beginning-level questions on JSP. More advanced coders should post to Pro JSP.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the JSP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 29th, 2006, 08:48 PM
Registered User
 
Join Date: Aug 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default cant't read datas from database

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.handle JspException(JspServletWrapper.java:504)
    org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:393)
    org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
    org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.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.getR emoteAddr()%></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("ÂÛ̳I d")%>&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!
 
Old October 2nd, 2006, 10:52 PM
Authorized User
 
Join Date: Dec 2005
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Why not use type 4 driver?

JAVA Tutorials Hot Web Resources





Similar Threads
Thread Thread Starter Forum Replies Last Post
Database or object is read-only ryanb Access ASP 25 January 17th, 2014 06:36 PM
how get the datas from browser machine azymd777 SQL Language 1 July 23rd, 2007 09:15 AM
no datas displayed in subreports suji_dec08 Crystal Reports 0 April 11th, 2007 12:56 AM
Read only Database error larry101 Classic ASP Databases 4 September 11th, 2004 08:41 AM
Sending datas from the first page to the next ones mcber35 Access VBA 2 July 28th, 2004 11:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.