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 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");URL Examples
The complete connection URL format used with the driver manager is:
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. See "Connection String Properties" for a list of connection properties and their values.The following example shows a typical connection URL:
jdbc:microsoft:sqlserver://server1:1433;user=test;password=secret
![]() |
Previous Page |
![]() |
Next Page |
![]() |
Synchronize with Contents |