java怎么把oracle的游标里面的结果集显示到页面
1个回答
推荐于2016-01-25 · 知道合伙人软件行家
关注
展开全部
Connection connection = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String dbUrl = "jdbc:oracle:thin:@10.0.0.129:1521:cdfy";
String user = "prstest";
String password = "prstest";
String sql="select * from wangsonghuai";
connection=DriverManager.getConnection(dbUrl,user,password);
pstmt = (PreparedStatement) connection.prepareStatement(sql);
rs=pstmt.executeQuery();
while(rs.next()){%>
<TR onmouseover="style.backgroundColor='#0EF'" onmouseout="style.backgroundColor=''" >
<TD><%=rs.getString("CONTACTINFOID")%></TD>
<TD><%=rs.getString("CONTACTMAN")%></TD>
<TD><%=rs.getString("DEPARTMENT")%></TD>
<TD><%=rs.getString("MOBILEPHONE")%></TD>
<TD><%=rs.getString("PHONE")%></TD>
</TR> <% }
}
catch (ClassNotFoundException cnfex) {
cnfex.printStackTrace();
}
catch (SQLException sqlex) {
sqlex.printStackTrace();
} catch (Exception e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String dbUrl = "jdbc:oracle:thin:@10.0.0.129:1521:cdfy";
String user = "prstest";
String password = "prstest";
String sql="select * from wangsonghuai";
connection=DriverManager.getConnection(dbUrl,user,password);
pstmt = (PreparedStatement) connection.prepareStatement(sql);
rs=pstmt.executeQuery();
while(rs.next()){%>
<TR onmouseover="style.backgroundColor='#0EF'" onmouseout="style.backgroundColor=''" >
<TD><%=rs.getString("CONTACTINFOID")%></TD>
<TD><%=rs.getString("CONTACTMAN")%></TD>
<TD><%=rs.getString("DEPARTMENT")%></TD>
<TD><%=rs.getString("MOBILEPHONE")%></TD>
<TD><%=rs.getString("PHONE")%></TD>
</TR> <% }
}
catch (ClassNotFoundException cnfex) {
cnfex.printStackTrace();
}
catch (SQLException sqlex) {
sqlex.printStackTrace();
} catch (Exception e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询