03.07.2015 Views

DataDirect Connect for JDBC User's Guide and ... - Stylus Studio

DataDirect Connect for JDBC User's Guide and ... - Stylus Studio

DataDirect Connect for JDBC User's Guide and ... - Stylus Studio

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

28 Chapter 2 Using <strong>DataDirect</strong> <strong>Connect</strong> <strong>for</strong> <strong>JDBC</strong> Drivers<br />

<strong>Connect</strong>ing Through the <strong>JDBC</strong> Driver Manager<br />

One way of connecting to a database is through the <strong>JDBC</strong> Driver<br />

Manager, using the DriverManager.get<strong>Connect</strong>ion method. This<br />

method uses a string containing a URL. The following code shows<br />

an example of using the <strong>JDBC</strong> Driver Manager to connect to<br />

Microsoft SQL Server while passing the user name <strong>and</strong> password:<br />

Class.<strong>for</strong>Name("com.ddtek.jdbc.sqlserver.SQLServerDriver");<br />

<strong>Connect</strong>ion conn = DriverManager.get<strong>Connect</strong>ion<br />

("jdbc:datadirect:sqlserver://server1:1433;User=test;Password=secret");<br />

URL Examples<br />

The complete connection URL <strong>for</strong>mat used with the Driver<br />

Manager is:<br />

jdbc:datadirect:drivername://hostname:port[;property=<br />

value...]<br />

where:<br />

drivername<br />

hostname<br />

port<br />

property=value<br />

is the name of the <strong>DataDirect</strong> <strong>Connect</strong> <strong>for</strong><br />

<strong>JDBC</strong> driver, <strong>for</strong> example, sybase.<br />

is the TCP/IP address or TCP/IP host name of<br />

the server to which you are connecting.<br />

NOTE: Untrusted applets cannot open a<br />

socket to a machine other than the<br />

originating host.<br />

is the number of the TCP/IP port.<br />

specifies connection properties. For a list of<br />

connection properties <strong>and</strong> their valid<br />

values, see the appropriate <strong>DataDirect</strong><br />

<strong>Connect</strong> <strong>for</strong> <strong>JDBC</strong> driver chapter.<br />

<strong>DataDirect</strong> <strong>Connect</strong> <strong>for</strong> <strong>JDBC</strong> User’s <strong>Guide</strong> <strong>and</strong> Reference

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!