主题:JSP 连接SQL SERVER 2000数据库 例程
JSP 连接SQL SERVER 2000数据库 例程
[url=http://www.now.cn/indexr.php?r=!bbsbaga08]【在线QQ讨论群】
JSP数据库连接说明实例如下:
<%@page contentType="text/html;charset=gb2312"%>
<%
//声名
java.sql.Connection sqlConn;
java.sql.Statement sqlStmt;
java.sql.ResultSet sqlRst;
//regiester jdbc driver
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
//connect to the database
sqlConn=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://192.168.0.2:1433;DatabaseName=pubs;SelectMethod=direct","dxxx","");
//create the driver handle
sqlStmt=sqlConn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
//excute sql
sqlRst=sqlStmt.executeQuery("select title_id,title,type from titles");
%>
<html>
<head>
<title>Linux-JSP-JDBC-MYSQL TESTING -SELETCT copyright sanry@newsea.net </title>
</head>
<body>
<table border="1" cellspace ="0" align="center">
<tr>
<th>title </th>
<th>type </th>
</tr>
<% while(sqlRst.next()) {%>
<tr>
<td> <%=sqlRst.getString(1)%></td>
<td><%=sqlRst.getString(2)%></td>
</tr>
<%}%>
</table>
</body>
</html>
<%
sqlRst.close();
sqlStmt.close();
sqlConn.close();
%>
[/url]
--------------------------------------------------------------------------------
目前我采用的空间是JSP+SQL SERVER 2000类型的,大家有关于JSP方面的编程问题,欢迎一起讨论:)
[url=http://www.now.cn/indexr.php?r=!bbsbaga08]详情点击进入[/url]
[url=http://www.now.cn/indexr.php?r=!bbsbaga08]【在线QQ讨论群】
JSP数据库连接说明实例如下:
<%@page contentType="text/html;charset=gb2312"%>
<%
//声名
java.sql.Connection sqlConn;
java.sql.Statement sqlStmt;
java.sql.ResultSet sqlRst;
//regiester jdbc driver
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
//connect to the database
sqlConn=java.sql.DriverManager.getConnection("jdbc:microsoft:sqlserver://192.168.0.2:1433;DatabaseName=pubs;SelectMethod=direct","dxxx","");
//create the driver handle
sqlStmt=sqlConn.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
//excute sql
sqlRst=sqlStmt.executeQuery("select title_id,title,type from titles");
%>
<html>
<head>
<title>Linux-JSP-JDBC-MYSQL TESTING -SELETCT copyright sanry@newsea.net </title>
</head>
<body>
<table border="1" cellspace ="0" align="center">
<tr>
<th>title </th>
<th>type </th>
</tr>
<% while(sqlRst.next()) {%>
<tr>
<td> <%=sqlRst.getString(1)%></td>
<td><%=sqlRst.getString(2)%></td>
</tr>
<%}%>
</table>
</body>
</html>
<%
sqlRst.close();
sqlStmt.close();
sqlConn.close();
%>
[/url]
--------------------------------------------------------------------------------
目前我采用的空间是JSP+SQL SERVER 2000类型的,大家有关于JSP方面的编程问题,欢迎一起讨论:)
[url=http://www.now.cn/indexr.php?r=!bbsbaga08]详情点击进入[/url]