public DBConnect()
{ driver="com.microsoft.sqlserver.jdbc.SQLServerDriver";
url="jdbc:sqlserver://localhost:1433;databaseName=mytest";
username="sa";
password="123";
try{
Class.forName(driver);
conn=DriverManager.getConnection(url,username,password);
statement=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
}
catch(java.lang.ClassNotFoundException e)
{
System.err.println("连接错误:" + e.getMessage());
}
catch(SQLException e)
{
System.err.println("连接错误:"+ e.getMessage());
}
}
SQL Server2000数据库链接是:
driver="com.microsoft.jdbc.sqlserver.SQLServerDriver";
url="jdbc:microsoft:sqlserver://localhost:1433s;databaseName=mytest";