Hello,
I made a custom connection source that I want to use. (Source follows
this message.) However, when I attempt to use my BoneCP connection
source in my config, I get the error, "ERROR JDBC contains an invalid
element or attribute "BoneCP"". What else do I need to do to make my
custom connection source available in the configuration?
I'm hoping the answer will also apply to a custom appender and manager
I've written, neither of which work because they also cannot be
instantiated from the configuration, however the error is a class not
found error.
Thanks,
Jeff
Source:
/**
* Copyright (c) Bit Gladiator on 2014.
*/
@Plugin(name = "BoneCP", category="Core", elementType =
"connectionSource", printObject = true)
public class BoneCPConnectionSource implements ConnectionSource {
private static final Logger LOGGER = StatusLogger.getLogger();
private final BoneCP pool;
private BoneCPConnectionSource(final BoneCP pool) {
this.pool = pool;
}
@PluginFactory
public static BoneCPConnectionSource createConnectionSource(
@PluginAttribute("url") final String url,
@PluginAttribute("username") final String username,
@PluginAttribute("password") final String password,
@PluginAttribute("partitionCount") final String partitionCount,
@PluginAttribute("connectionsPerPartition") final String
connectionsPerPartition
) {
BoneCPConfig config = new BoneCPConfig();
config.setJdbcUrl(url);
config.setUsername(username);
config.setPassword(password);
config.setPartitionCount(Integer.parseInt(partitionCount));
config.setMaxConnectionsPerPartition(Integer.parseInt(connectionsPerPartition));
try {
BoneCP pool = new BoneCP(config);
return new BoneCPConnectionSource(pool);
} catch (SQLException e) {
LOGGER.error("Failed to create the connection pool.");
return null;
}
}
@Override
public Connection getConnection() throws SQLException {
return pool.getConnection();
}
@Override
public String toString() {
return pool.getConfig().toString();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]