Methods Summary |
---|
protected static synchronized void | checkIn(java.sql.Connection c)
try {
c.close();
}
catch (SQLException e) {
System.err.println(e.getMessage() +
" closing connection");
}
|
public static synchronized java.sql.Connection | checkOut()
return checkOut("Database");
|
public static synchronized java.sql.Connection | checkOut(java.lang.String baseName)
boolean found = false;
OracleConnectionCacheImpl cached = null;
Connection connection = null;
if (verbose) {
System.out.println("There are " +
Integer.toString(numberImplementations) +
" connections in the cache");
System.out.println(
"Searching for a matching implementation...");
}
for (int i=0;!found && i<numberImplementations;i++) {
if (verbose) {
System.out.println("Vector entry " + Integer.toString(i));
}
cached = (OracleConnectionCacheImpl)cachedImplementations.get(i);
if (cached.getDescription().equals(baseName)) {
if (verbose) {
System.out.println("found cached entry " +
Integer.toString(i) +
" for " + baseName);
}
found = true;
}
}
if (!found) {
if (verbose) {
System.out.println("Cached entry not found ");
System.out.println("Allocating new entry for " + baseName);
}
try {
cached = new OracleConnectionCacheImpl(
getConnectionPoolDataSource(baseName));
cached.setDescription(baseName);
cachedImplementations.add(cached);
numberImplementations++;
}
catch (SQLException e) {
System.err.println(e.getMessage() +
" creating a new implementation for " + baseName);
}
}
if (cached != null) {
try {
connection = cached.getConnection();
}
catch (SQLException e) {
System.err.println(e.getMessage() +
" getting connection for " + baseName);
}
}
return connection;
|
public static javax.sql.ConnectionPoolDataSource | getConnectionPoolDataSource(java.lang.String baseName)
Context context = null;
ConnectionPoolDataSource cpds = null;
try {
Properties properties = new Properties();
properties.setProperty(
Context.INITIAL_CONTEXT_FACTORY,
"com.sun.jndi.fscontext.RefFSContextFactory");
properties.setProperty(
Context.PROVIDER_URL,
"file:/JNDI/JDBC");
context = new InitialContext(properties);
cpds = (ConnectionPoolDataSource)context.lookup(baseName);
}
catch (NamingException e) {
System.err.println(e.getMessage() +
" creating JNDI context for " + baseName);
}
return cpds;
|
public static java.lang.String[] | getReport()
int line = 0;
String[] lines =
new String[numberImplementations * 7];
OracleConnectionCacheImpl cached = null;
for (int i=0;i < numberImplementations;i++) {
cached = (OracleConnectionCacheImpl)cachedImplementations.get(i);
lines[line++] = cached.getDescription() + ":";
switch (cached.getCacheScheme()) {
case OracleConnectionCacheImpl.DYNAMIC_SCHEME:
lines[line++] = "Cache Scheme = DYNAMIC_SCHEME";
break;
case OracleConnectionCacheImpl.FIXED_RETURN_NULL_SCHEME:
lines[line++] = "Cache Scheme = FIXED_RETURN_NULL_SCHEME";
break;
case OracleConnectionCacheImpl.FIXED_WAIT_SCHEME:
lines[line++] = "Cache Scheme = FIXED_WAIT_SCHEME";
break;
}
lines[line++] = "Minimum Limit = " +
Integer.toString(cached.getMinLimit());
lines[line++] = "Maximum Limit = " +
Integer.toString(cached.getMaxLimit());
lines[line++] = "Cache Size = " +
Integer.toString(cached.getCacheSize());
lines[line++] = "Active Size = " +
Integer.toString(cached.getActiveSize());
lines[line++] = " ";
}
return lines;
|
public static void | setVerbose(boolean v)
verbose = v;
|