永发信息网

在JSP里面编程时,如何根据可选框里的条件输出数据库中的某一行的内容啊?

答案:1  悬赏:60  手机版
解决时间 2021-03-31 19:22
  • 提问者网友:放下
  • 2021-03-30 22:01
在JSP里面编程时,如何根据可选框里的条件输出数据库中的某一行的内容啊?
最佳答案
  • 五星知识达人网友:鱼芗
  • 2021-03-30 23:27

<%

String id= request.getParameter( "id" );Connection con = null;
Statement sm = null;
ResultSet rs = null;
try
{
Class.forName("org.postgresql.Driver").newInstance();
String url="jdbc:postgresql://localhost/Anti-fatigue Design";
String user="postgres";
String password="123456";
con = DriverManager.getConnection(url,user,password);
sm = con.createStatement();
rs = sm.executeQuery("select * from iron where id='" +id + "'");

while(rs.next())
{
%>

<%=rs.getInt(1)%>
<%=rs.getString(2)%>
<%=rs.getString(3)%>
<%=rs.getString(4)%>
<%=rs.getString(5)%>
<%=rs.getString(6)%>
...

<%}
}
catch(Exception e)
{
e.printStackTrace();
}
%>






追问运行不出来啊,大神?出现以下错误:

追答忘了,你是在jsp中
%>

<%=rs.getInt(1)%>
<%=rs.getString(2)%>
<%=rs.getString(3)%>
<%=rs.getString(4)%>
<%=rs.getString(5)%>
<%=rs.getString(6)%>
...

<%追问还是不行啊,大神。我选了可选框中的值并点击提交,还是不显示内容,问题出在哪里了啊追答
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯