jsp简单连接SQL_Server2000数据库的方法
来源:
中文源码网 浏览:202 次 日期:2024-05-03 19:56:55
【下载文档: jsp简单连接SQL_Server2000数据库的方法.txt 】
jsp简单连接SQL Server2000数据库的方法
本文实例讲述了jsp简单连接SQL Server2000数据库的方法。分享给大家供大家参考。具体如下:
package util;
import java.sql.Connection;
import java.sql.DriverManager;
public class ConnDB {
public static String driver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
public static String url="jdbc:microsoft:sqlserver://localhost:1433;databaseName=temp";
public static String username="sa";
public static String password="";
public static Connection con=null;
public static Connection getConnection()
{
try {
Class.forName(driver);
con=DriverManager.getConnection(url,username,password);
System.err.println("链接成功");
} catch (Exception e) {
e.printStackTrace();
}
return con;
}
public static void main(String[] args) {
ConnDB.getConnection();
}
}
希望本文所述对大家的JSP程序设计有所帮助。