One way of connecting to a database is through the JDBC driver manager using the method DriverManager.getConnection. This method uses a string containing a URL. The following is an example of using the JDBC driver manager to connect to Microsoft SQL Server 2000 while passing the user name and password: Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection conn = DriverManager.getConnection ("jdbc:microsoft:sqlserver://server1:1433;User=test;Password=secret");
Statement stmt;
要把安装生成的三个文件放到tomcathome\common\lib\下
Connection conn = DriverManager.getConnection
("jdbc:microsoft:sqlserver://server1:1433;User=test;Password=secret");