原代码:

03-05-08 pingfeng



// <%@ page language="java" import="java.sql.*"%>
<%@ page contentType=
"text/html;charSet=gb2312"%>
<%@ page import=
"com.microsoft.jdbc.sqlserver.SQLServerDriver"%>
<html>
<head>
<title>当前票数统计</title>
<meta http-equiv=
"Content-Type" content="text/html; charset=gb2312">
<body bgcolor=
"#FFFFFF">
<%
Connection con=null;
Statement stm=null;
String SQLText;
ResultSet Rs_result=null;

Class.forName(
"com.microsoft.jdbc.sqlserver.SQLServerDriver");
con=DriverManager.getConnection(
"jdbc:microsoft:sqlserver://192.168.9.114:1433;DatabaseName=webdev","sa","");
stm=con.createStatement();

SQLText =
"select * from zd_xt_qkdm";
Rs_result=stm.executeQuery(SQLText);
String companyName,voteNum;
while(Rs_result.next())
{
companyName=Rs_result.getString(1);
voteNum=Rs_result.getString(2);

%>
<%=companyName%>
<%=voteNum%>
<% out.println(
"<br>");
}
out.println(
"<br>数据库链接成功!");
Rs_result.close();
stm.close();
con.close();
%>
</body>
</html>