一个简单在jsp页面中连接sqlserver数据库的小实例。
<%@ page contentType="text/html; charset=GBK" %>
<html>
<head>
<title>connect the db</title>
</head>
<%@ page import="java.sql.*"%>//不要忘了引入sql 包
<body bgcolor="#ffffff">
<%Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:message_DSN"; // message_DSN 为你的用户数据源名称;
String user="";
String password=""; // 用户名和密码在此都设为空;
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement();
伊图教程网[www.etoow.com]
http://www.etoow.com/html/2007-05/1178865784.html
String sql="select * from message1"; //message1为数据源所在库中的一张表;
一个简单的JSP连接SQL Server数据库的小实例
'http://www.etoow.com/html/2007-05/1178865784.html