jsp文档怎么读取2次以上数据库中的文本
<tdwidth="382"height="28"class="navText><%StringsDBDriver="sun.jdbc.odbc.JdbcOdbcDriv...
<td width="382" height="28" class="navText >
<%String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:com";
Class.forName(sDBDriver);
Connection con = DriverManager.getConnection(sConnStr);
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from news where news_no=1";
ResultSet rs=null;
int i=1;//i用来计数几条内容
String book_page;
try{
rs=stmt.executeQuery(sql);
while(rs.next())
{//此处可把书的简介页面地址作为一个数据库字段读入href
book_page=rs.getString("news_no");
out.print("<a href="+book_page+">"+rs.getString("news_text")+"</a><br>");
i++;
if(i>1) break;
}
}finally{
rs.close();
stmt.close();
con.close();
}
%></td>
我现在要用在另一个表格里 并且改成String sql="select * from news where news_no=2";~读取编号2里的文本怎么弄阿 展开
<%String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:com";
Class.forName(sDBDriver);
Connection con = DriverManager.getConnection(sConnStr);
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from news where news_no=1";
ResultSet rs=null;
int i=1;//i用来计数几条内容
String book_page;
try{
rs=stmt.executeQuery(sql);
while(rs.next())
{//此处可把书的简介页面地址作为一个数据库字段读入href
book_page=rs.getString("news_no");
out.print("<a href="+book_page+">"+rs.getString("news_text")+"</a><br>");
i++;
if(i>1) break;
}
}finally{
rs.close();
stmt.close();
con.close();
}
%></td>
我现在要用在另一个表格里 并且改成String sql="select * from news where news_no=2";~读取编号2里的文本怎么弄阿 展开
2个回答
展开全部
<td width="382"宽尺 height="28" class="navText >
<%String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:com";
Class.forName(sDBDriver);
Connection con = DriverManager.getConnection(sConnStr);
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from news where news_no=1";
ResultSet rs=null;
int i=1;//i用来计数几条内容
String book_page;
rs=stmt.executeQuery(sql);
while(rs.next())
{//此处可把书的简介页面地址作春嫌为一个数据库字段读入href
book_page=rs.getString("news_no");
out.print("<a href="+book_page+">"+rs.getString("news_text")+"</a><br>");
i++;
if(i>1) break;
}
%></td>
<td width="382" height="28" class="navText >
<%
sql="select * from news where news_no=2";
i=1;//i用来计数几条内容
rs=stmt.executeQuery(sql);
while(rs.next())
{//此处可把书的简介页面地址作为一个数据库字段读入href
book_page=rs.getString("news_no");
out.print("<a href="+book_page+">"慎森高+rs.getString("news_text")+"</a><br>");
i++;
if(i>1) break;
}
rs.close();
stmt.close();
con.close();
%></td>
<%String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
String sConnStr = "jdbc:odbc:com";
Class.forName(sDBDriver);
Connection con = DriverManager.getConnection(sConnStr);
Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from news where news_no=1";
ResultSet rs=null;
int i=1;//i用来计数几条内容
String book_page;
rs=stmt.executeQuery(sql);
while(rs.next())
{//此处可把书的简介页面地址作春嫌为一个数据库字段读入href
book_page=rs.getString("news_no");
out.print("<a href="+book_page+">"+rs.getString("news_text")+"</a><br>");
i++;
if(i>1) break;
}
%></td>
<td width="382" height="28" class="navText >
<%
sql="select * from news where news_no=2";
i=1;//i用来计数几条内容
rs=stmt.executeQuery(sql);
while(rs.next())
{//此处可把书的简介页面地址作为一个数据库字段读入href
book_page=rs.getString("news_no");
out.print("<a href="+book_page+">"慎森高+rs.getString("news_text")+"</a><br>");
i++;
if(i>1) break;
}
rs.close();
stmt.close();
con.close();
%></td>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询