guoqing_w
发贴: 19
|
于 2005-04-14 13:06
用是的MYSQL数据库 neiro字段是LONGTEXT类型的
<%@ page contentType="text/html;charset=gb2312"%> <%@ page import="java.sql.*"%> <%@ page import="java.io.*" %> <% ResultSet result; String textValue,sql; try{ Class.forName("org.gjt.mm.mysql.Driver").newInstance(); } catch(java.lang.ClassNotFoundException c){ c.printStackTrace(); } try{ Connection con=DriverManager.getConnection("jdbc:mysql://localhost/qx?user=root&password="); String t=request.getParameter("title").trim(); StringBuffer buffer=new java.lang.StringBuffer().append("'").append(t).append("'"); sql="SELECT title,neiro,dtime FROM jtnewtable WHERE title="+t; result=con.executeQuery(sql); } catch(java.sql.SQLException s){ s.printStackTrace(); } if(result==null){ %> <p align="center"><font color="#FF0000" size="5"><b>没找到你所选择的新闻!</b></font></p> <% } else{ %> <p align="center"><font size="5" color="#808080"><%=result.getString("title")%></font></p><hr> <% InputStream textStream = result.getAsciiStream( "neiro" ); BufferedReader textReader = new BufferedReader( new InputStreamReader( textStream ) ); textValue = textReader.readLine(); while ( textValue != null ) { textValue = textReader.readLine(); %> <p align="center"><font size="2" color="#808080"><%=textValue%></font></p> <% } %> <p align="right"><font size="2" color="#808080">发布时间:<%=result.getString("dtime")%></font></p> <% } %>
错误 symbol : method executeQuery(java.lang.String) location: interface java.sql.Connection result=con.executeQuery(sql);
Illegal operation on empty result set 错误
why edited on 2005-04-16 10:47
|