tomcat编写jsp怎么链接sql2000的数据库,需要怎么配置,我是新手,刚刚接触

来源:百度知道 编辑:UC知道 时间:2024/06/21 22:43:20

<%@ page contentType="text/html;charset=GB2312" language="java"%>
<%@ page import="java.sql.*,java.io.*" %>
<html>
<head>
<title>使用JDBC添加数据</title>
</head>
<body>
<center><h2>
使用JDBC-ODBC向SQL Server数据库添加数据
</h2></center>

<%
//装载驱动程序
Class.forName"com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
//创建连接
String url="jdbc:microsoft:sqlserver://你的SQL服务地址:1433; DatabaseName=student";
//student为你的数据库的
String user="sa";
String password="sa"; //
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);

stmt.execute("insert into student(sno,sname,ssex,Sclass,school)values('001','丁阳','女'