use of com.adaptris.core.jdbc.JdbcConnection in project interlok by adaptris.
the class JdbcQueryServiceCase method createConstantService.
protected static JdbcDataQueryService createConstantService(String constant) {
JdbcDataQueryService service = new JdbcDataQueryService();
JdbcConnection connection = new JdbcConnection(PROPERTIES.getProperty(JDBC_QUERYSERVICE_URL), PROPERTIES.getProperty(JDBC_QUERYSERVICE_DRIVER));
service.setConnection(connection);
service.setStatementCreator(new ConfiguredSQLStatement(QUERY_SQL));
StatementParameter sp = new StatementParameter();
sp.setQueryClass("java.lang.String");
sp.setQueryType(StatementParameter.QueryType.constant);
sp.setQueryString(constant);
service.addStatementParameter(sp);
return service;
}
use of com.adaptris.core.jdbc.JdbcConnection in project interlok by adaptris.
the class JdbcQueryServiceCase method buildExamples.
@Override
protected List<JdbcService> buildExamples() {
ArrayList<JdbcService> objects = new ArrayList<>();
JdbcDataQueryService service = new JdbcDataQueryService();
try {
JdbcConnection connection = new JdbcConnection("jdbc:mysql://localhost:3306/mydatabase", "com.mysql.jdbc.Driver");
KeyValuePairSet connectionProperties = new KeyValuePairSet();
connectionProperties.add(new KeyValuePair("useCompression", "true"));
connection.setConnectionProperties(connectionProperties);
connection.setConnectionAttempts(2);
connection.setConnectionRetryInterval(new TimeInterval(3L, "SECONDS"));
service.setConnection(connection);
service.setResultSetTranslator(configureForExample(createTranslatorForConfig()));
String additionalParams = "";
boolean first = true;
for (QueryClasses qc : QueryClasses.values()) {
service.addStatementParameter(qc.create());
if (first) {
additionalParams += qc.name() + "=?";
first = false;
} else {
additionalParams += " AND " + qc.name() + "=?";
}
}
service.setStatementCreator(new ConfiguredSQLStatement("SELECT StringColumn1, DateColumn2, IntegerColumn3, BlobColumn, ClobColumn FROM tablename WHERE " + additionalParams));
} catch (Exception e) {
throw new RuntimeException(e);
}
objects.add(service);
return objects;
}
use of com.adaptris.core.jdbc.JdbcConnection in project interlok by adaptris.
the class JdbcQueryServiceCase method createMessageIdService.
protected static JdbcDataQueryService createMessageIdService() {
JdbcDataQueryService service = new JdbcDataQueryService();
JdbcConnection connection = new JdbcConnection(PROPERTIES.getProperty(JDBC_QUERYSERVICE_URL), PROPERTIES.getProperty(JDBC_QUERYSERVICE_DRIVER));
service.setConnection(connection);
service.setStatementCreator(new ConfiguredSQLStatement(QUERY_SQL));
StatementParameter sp = new StatementParameter();
sp.setQueryClass("java.lang.String");
sp.setQueryType(StatementParameter.QueryType.id);
service.addStatementParameter(sp);
return service;
}
use of com.adaptris.core.jdbc.JdbcConnection in project interlok by adaptris.
the class JdbcServiceListTest method retrieveObjectForSampleConfig.
@Override
protected JdbcServiceList retrieveObjectForSampleConfig() {
JdbcConnection connection = new JdbcConnection();
connection.setConnectUrl("jdbc:mysql://localhost:3306/mydatabase");
connection.setAutoCommit(false);
connection.setConnectionAttempts(2);
connection.setConnectionRetryInterval(new TimeInterval(3L, "SECONDS"));
JdbcServiceList list = new JdbcServiceList();
list.setConnection(connection);
StaticIdentitySequenceNumberService s1 = new StaticIdentitySequenceNumberService();
s1.setIdentity("first_id");
s1.setMetadataKey("sequence_number_1");
s1.setNumberFormat(SequenceNumberCase.DEFAULT_NUMBER_FORMAT);
StaticIdentitySequenceNumberService s2 = new StaticIdentitySequenceNumberService();
s2.setIdentity("another_id");
s2.setMetadataKey("sequence_number_2");
s2.setNumberFormat(SequenceNumberCase.DEFAULT_NUMBER_FORMAT);
list.add(s1);
list.add(s2);
return list;
}
use of com.adaptris.core.jdbc.JdbcConnection in project interlok by adaptris.
the class StaticIdentitySequenceNumberServiceTest method createServiceForTests.
private StaticIdentitySequenceNumberService createServiceForTests(boolean createConnection) {
StaticIdentitySequenceNumberService service = new StaticIdentitySequenceNumberService();
if (createConnection) {
service.setConnection(new JdbcConnection(PROPERTIES.getProperty(JDBC_SEQUENCENUMBER_URL), PROPERTIES.getProperty(JDBC_SEQUENCENUMBER_DRIVER)));
}
service.setIdentity(DEFAULT_ID);
service.setMetadataKey(DEFAULT_METADATA_KEY);
service.setNumberFormat(DEFAULT_NUMBER_FORMAT);
return service;
}
Aggregations