You can use Connection objects to connect to a JDBC-compliant database. When you create an instance of an implementation of the Data interface, you pass a Connection object to the overloaded DataFactory.getData() method.
For example, you could create a new Data object with application logic that is similar to this:
Connection con = DriverManager.getConnection(...);
Data data = DataFactory.getData(con);
You can use all of the methods in the Data object.
The Data interface supports the following JDBC methods on Connection objects:
You can use JDBC DataSource objects to connect to a JDBC-compliant database. When you create an instance of an implementation of the Data interface, you pass a DataSource object to the overloaded DataFactory.getData() method.
For example, you could create a new Data object with application logic that is similar to this:
import javax.naming.*;
import javax.sql.*;
...
Context ctx=new InitialContext();
DataSource ds=(DataSource)ctx.lookup("...");
Data data = DataFactory.getData(ds);
The DataFactory creates a java.sql.Connection object, then creates a Data object which uses the Connection to access the underlying data store. If the application then needs the implicitly-created Connection, for example to modify a Connection property, it can acquire a reference to it using the getConnection() method of the Data object.