After you define such an interface, you run the pureQuery Generator to create a class that implements the interface.
The com.ibm.pdq.runtime.factory.DataFactory class provides a means for your application to instantiate implementations of the interfaces in which you define your annotated methods.
When you instantiate an implementation of a custom interface so that you can run SQL against a database, you need to have an open connection to that database.
For example, you can instantiate an implementation with application logic similar to this:
Connection con = DriverManager.getConnection(...); CustomerQuery cQuery = DataFactory.getData(CustomerQuery.class, con);
When you instantiate an implementation of a custom interface so that you can run SQL against a data source, that data source must be open.
For example, you can instantiate an implementation with application logic similar to this:
import javax.naming.*; import javax.sql.*; ... Context ctx=new InitialContext(); DataSource ds=(DataSource)ctx.lookup("..."); CustomerQuery cQuery = DataFactory.getData(CustomerQuery.class, ds);
The DataFactory creates a java.sql.Connection, then instantiates 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 by using the getConnection() method of the Data object.