haoyue
发贴: 24
积分: 0
|
于 2004-08-08 18:29
这个程序找到到连接用的驱动程序是SQL Sever2000的,请帮我一下。 /*连接到SQL Sever 2000的数据库*/
import java.sql.*; import java.io.*; import java.util.*;
public class ContoSQL { public static void main(String args[]) { String url="jdbc:JTurbo://localhost:1433/student"; //上一语句表示连接的是本机上1433端口名为student的数据库 //其中1433是SQL Sever默认的端口 Connection con=null; Statement sm=null; String command=null; try { DriverManager.registerDriver(new com.ashna.jturbo.driver.Driver()); System.out.println("驱动程序已加载"); con=DriverManager.getConnection(url,"SA","a"); //"SA"是SQLSever的系统管理员账户,密码是"a" System.out.println("OK:已成功连接到数据库"); } catch(Exception ex) { System.out.println(ex.getMessage()); return; } } }
haoyue edited on 2004-08-09 11:46
|