Databases Reference
In-Depth Information
•
javax.sql.XADataSource
, which allows your applications to use distrib-
uted transactions through the Java Transaction API (JTA)
Applications can call a DataDirect JDBC data source using a logical name to
retrieve the
javax.sql.DataSource
object. This object loads the specified driver
and can establish a connection to the database.
Once the data source has been registered with JNDI, your JDBC application
can use it, as shown in the following example:
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("EmployeeDB");
Connection conn = ds.getConnection("scott", "tiger");
In this example, the JNDI environment is initialized first. Next, the initial
naming context is used to find the logical name of the data source (
EmployeeDB
).
The
Context.lookup()
method returns a reference to a Java object, which is
narrowed to a
javax.sql.DataSource
object. Finally, the
DataSource.
getConnection()
method is called to establish a connection with the database.
ADO.NET Data Providers
After you install the data provider, you can connect from your application to
your database with a connection string. You can configure the connection string
either by using the common programming model or by using the provider-
specific objects.
Each DataDirect Technologies data provider uses a connection string to pro-
vide information needed to connect to a specific database. The connection infor-
mation is defined by connection string options.
The connection options have the following form:
option=value
Each connection string option value pair is separated by a semicolon. For
example:
Host=Accounting1;Port=50000;User ID=johng;Password=test01;
Database=Test