Show Table of Contents
2.2. Define a Managed Connection Factory
- Extend the
org.teiid.resource.spi.BasicManagedConnectionFactoryclass, providing an implementation for thecreateConnectionFactory()method. This method will create and return an instance of a Connection Factory. - Define an attribute for each configuration variable, and then provide both "getter" and "setter" methods for them. This class will define various configuration variables (such as user, password, and URL) used to connect to the datasource.
See the following code for an example.
public class MyManagedConnectionFactory extends BasicManagedConnectionFactory
{
@Override
public BasicConnectionFactory createConnectionFactory() throws ResourceException
{
return new MyConnectionFactory();
}
// config property name (metadata for these are defined inside the ra.xml)
String userName;
public String getUserName() { return this.userName; }
public void setUserName(String name){ this.userName = name; }
// config property count (metadata for these are defined inside the ra.xml)
Integer count;
public Integer getCount() { return this.count; }
public void setCount(Integer value) { this.count = value; }
}
Important
Use only
java.lang objects as the attributes. DO NOT use Java primitives for defining and accessing the properties.

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.