Connecting Through the JDBC Driver Manager
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 connecting to SQL Server using the JDBC Driver Manager:
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver"); Connection conn = DriverManager.getConnection ("jdbc:microsoft:sqlserver://server1:1433","username","password");URL Examples
jdbc:microsoft:sqlserver://hostname
:port[;property=value...]
hostname is the TCP/IP address or TCP/IP host name of the server to which you are connecting.NOTE: Untrusted applets cannot open a socket to a machine other than the originating host. port is the number of the TCP/IP port. property=value specifies connection properties. For a list of connection properties and their valid values, see "SQL Server 2000 JDBC".The following example shows a typical connection URL:
jdbc:microsoft:sqlserver://server1:1433;user=test;password=secret
![]() |
Previous Page |
![]() |
Next Page |
![]() |
Synchronize with Contents |