大家帮我看看有什么错误

kangqing 2003-11-10 04:06:03
我的目的是要得到刚刚写入行结果集的id
<%@ page contentType="text/html;charset=gb2312"%>
<%@include file="data.jsp"%>
<%
String days=request.getParameter("days");
String sql="insert into diary (ddate) values ('"+days+"')";
try {
stmt.executeUpdate(sql);
out.println("×ÊÁÏÌí¼ÓÍê³É");
}
catch(Exception e){
out.println("");
};
String diaryid=null;
String sql1="select * from diary";
try{
rst=stmt.executeQuery(sql1);
rst.afterLast()+1;
diaryid=rst.getInt("id");
out.println(diaryid);
}
catch(Exception e)
{
out.println("");
}
%>
...全文
23 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
realby 2003-11-10
  • 打赏
  • 举报
回复

String diaryid=null;
String sql1="select * from diary";
try{
rst=stmt.executeQuery(sql1);
rst.last();
diaryid=rst.getString("id");
out.println(diaryid);
}
catch(Exception e)
{
out.println("");
}
%>
一楼对了-_-!
realby 2003-11-10
  • 打赏
  • 举报
回复
con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
String diaryid=null;错了~int diaryid=null;
rst.afterLast()+1;无返回值~+1错了
jokerjava 2003-11-10
  • 打赏
  • 举报
回复
conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
kangqing 2003-11-10
  • 打赏
  • 举报
回复
楼上的上面的参数怎么加??
情赐教~~~
truezerg 2003-11-10
  • 打赏
  • 举报
回复
查询时加上下面的参数,才可以执行.last();方法。另外是last();不是Last();

ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY

kangqing 2003-11-10
  • 打赏
  • 举报
回复
/diary/add.jsp:45: not a statement
rst.Last();
^

求大家告诉我吧这是什么错误。 我真的不知道了。
kangqing 2003-11-10
  • 打赏
  • 举报
回复
错误如下:::::
/diary/add.jsp:45: not a statement
rst.afterLast-1;
^
/diary/add.jsp:47: incompatible types
found : int
required: java.lang.String
diaryid=rst.getInt("id");
kangqing 2003-11-10
  • 打赏
  • 举报
回复
楼上的难道你也不确定么??
我尝试一下~~
ChDw 2003-11-10
  • 打赏
  • 举报
回复
好像应该是rst.last()吧

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧