<%!
Connection con= null;
Statement stmt = null;
ResultSet rs;
%>
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:jsjdj");
stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
String itemid=request.getParameter("id");
String sql = "select * from Notice where myid="+itemid+"";
rs = stmt.executeQuery(sql);
String title = rs.getString(2) ;
String content = rs.getString(3) ;
%>
<%
while(rs.next())
{
%>
<form action="update_do.jsp" method="post" name="mdfform"
onSubmit="javaScript: return validateMdf();">
<tr>
<td bgcolor="#cccccc" width="65" height="67"> 题目: </td>
<td bgcolor="#cccccc" width="298"><input type="text" name="title" height=""value="<%=title%>"></td>
</tr>
<tr>
<td bgcolor="#cccccc" width="65" height="107"> 内容: </td>
<td bgcolor="#cccccc" width="298"><textarea name="content" cols="30" rows="6"><%=content%></textarea></td>
</tr>
<tr align="center" bgcolor="#996633">
<td height="25" colspan="2"><input name="Submit" type="submit" value=" 提交 ">
<input name="Submit1" type="reset" value=" 重 设 ">
<input name="id" value="<%=itemid%>"></td>
</tr>
</form>
<% }
rs.close();
stmt.close();
con.close();
%>
小妹初学jsp,请高手指教下这是什么原因?
Connection con= null;
Statement stmt = null;
ResultSet rs;
%>
<%
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:jsjdj");
stmt=con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
String itemid=request.getParameter("id");
String sql = "select * from Notice where myid="+itemid+"";
rs = stmt.executeQuery(sql);
String title = rs.getString(2) ;
String content = rs.getString(3) ;
%>
<%
while(rs.next())
{
%>
<form action="update_do.jsp" method="post" name="mdfform"
onSubmit="javaScript: return validateMdf();">
<tr>
<td bgcolor="#cccccc" width="65" height="67"> 题目: </td>
<td bgcolor="#cccccc" width="298"><input type="text" name="title" height=""value="<%=title%>"></td>
</tr>
<tr>
<td bgcolor="#cccccc" width="65" height="107"> 内容: </td>
<td bgcolor="#cccccc" width="298"><textarea name="content" cols="30" rows="6"><%=content%></textarea></td>
</tr>
<tr align="center" bgcolor="#996633">
<td height="25" colspan="2"><input name="Submit" type="submit" value=" 提交 ">
<input name="Submit1" type="reset" value=" 重 设 ">
<input name="id" value="<%=itemid%>"></td>
</tr>
</form>
<% }
rs.close();
stmt.close();
con.close();
%>
小妹初学jsp,请高手指教下这是什么原因?
改成
String sql = "select * from Notice where myid='"+itemid+"'";
自己看啦。
你连接不对