如果用java在网页中显示数据库的内容 10
publicclassinformixconnect{publicstaticvoidmain(String[]args)throwsException{Connecti...
public class informixconnect {
public static void main (String[] args) throws Exception {
Connection conn = null;
String sql;
String url ="jdbc:informix-sqli://35.17.32.14:20042/esales2:informixserver=hzifxsvr2;NEWCODESET=gbk,8859-1,819;IFX_LOCK_MODE_WAIT=5;IFX_ISOLATION_LEVEL=1U;";
try{
Class.forName("com.informix.jdbc.IfxDriver");
conn = DriverManager.getConnection(url, "esales2", "L2e!ss43");
System.out.println("成功加载informix驱动");
Statement stmt = conn.createStatement();
sql = "select * from addv_rescue";
ResultSet rs = stmt.executeQuery(sql);
System.out.println (rs);
while(rs.next())
{ System.out.println(rs.getInt(1)+"\t"
+rs.getString(2)+"\t"
+rs.getString(3)+"\t"
+rs.getString(4)+"\t"
+rs.getString(5));
}
}
catch (SQLException e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}finally{
conn.close();
}
}
}
代码如上, 如何把sql的查询结果显示在网页上? 展开
public static void main (String[] args) throws Exception {
Connection conn = null;
String sql;
String url ="jdbc:informix-sqli://35.17.32.14:20042/esales2:informixserver=hzifxsvr2;NEWCODESET=gbk,8859-1,819;IFX_LOCK_MODE_WAIT=5;IFX_ISOLATION_LEVEL=1U;";
try{
Class.forName("com.informix.jdbc.IfxDriver");
conn = DriverManager.getConnection(url, "esales2", "L2e!ss43");
System.out.println("成功加载informix驱动");
Statement stmt = conn.createStatement();
sql = "select * from addv_rescue";
ResultSet rs = stmt.executeQuery(sql);
System.out.println (rs);
while(rs.next())
{ System.out.println(rs.getInt(1)+"\t"
+rs.getString(2)+"\t"
+rs.getString(3)+"\t"
+rs.getString(4)+"\t"
+rs.getString(5));
}
}
catch (SQLException e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}finally{
conn.close();
}
}
}
代码如上, 如何把sql的查询结果显示在网页上? 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询