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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

the following example, typically through a third-party<br />

connection pool tool:<br />

Context ctx = new InitialContext();<br />

<strong>Connect</strong>ionPoolDataSource ds =<br />

(<strong>Connect</strong>ionPoolDataSource)ctx.lookup(“jdbc/EmployeeDB”);<br />

pooled<strong>Connect</strong>ion pcon = ds.getPooled<strong>Connect</strong>ion(“scott”, “tiger”);<br />

In this example, the JNDI environment is first initialized. Next, the<br />

initial naming context is used to find the logical name of the<br />

<strong>JDBC</strong> data source (EmployeeDB). The Context.lookup() method<br />

returns a reference to a Java object, which is narrowed to a<br />

javax.sql.<strong>Connect</strong>ionPoolDataSource object. Finally, the<br />

<strong>Connect</strong>ionPoolDataSource.getPooled<strong>Connect</strong>ion() method is<br />

called to establish a connection with the underlying database.<br />

The <strong>DataDirect</strong> <strong>Connect</strong>ion Pool Manager is part of <strong>DataDirect</strong><br />

<strong>Connect</strong> <strong>for</strong> <strong>JDBC</strong>. See Appendix G “<strong>Connect</strong>ion Pool Manager” on<br />

page 263 <strong>for</strong> details.<br />

Specifying <strong>Connect</strong>ion Properties<br />

You can specify connection properties using the <strong>JDBC</strong> Driver<br />

Manager or <strong>DataDirect</strong> <strong>Connect</strong> <strong>for</strong> <strong>JDBC</strong> data sources. See “URL<br />

Examples” on page 28 <strong>for</strong> in<strong>for</strong>mation about specifying<br />

properties through the Driver Manager. See “Creating Data<br />

Sources” on page 31 <strong>for</strong> in<strong>for</strong>mation about example data sources<br />

that specify connection properties.<br />

For the list of the connection properties specific to each<br />

<strong>DataDirect</strong> <strong>Connect</strong> <strong>for</strong> <strong>JDBC</strong> driver, see the appropriate driver<br />

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!