gxz224
发贴: 6
积分: 0
|
于 2006-11-27 17:12
代码 import java.sql.*; public class Test1{ public static void main(String[] args){ try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); System.out.println("数据库驱动程序注册成功!"); String url ="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=northwind"; String user = "sa"; String password = ""; Connection conn = DriverManager.getConnection(url, user, password); System.out.println("数据库连接成功"); }catch(Exception e){ e.printStackTrace(); System.out.println("数据库连接失败"); } } }
(缩略图,点击图片链接看原图)
|