Search in sources :

Example 21 with JdbcConnection

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;
}
Also used : JdbcConnection(com.adaptris.core.jdbc.JdbcConnection)

Example 22 with JdbcConnection

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;
}
Also used : KeyValuePair(com.adaptris.util.KeyValuePair) TimeInterval(com.adaptris.util.TimeInterval) ArrayList(java.util.ArrayList) JdbcConnection(com.adaptris.core.jdbc.JdbcConnection) KeyValuePairSet(com.adaptris.util.KeyValuePairSet) ServiceException(com.adaptris.core.ServiceException) SQLException(java.sql.SQLException) CoreException(com.adaptris.core.CoreException) JdbcService(com.adaptris.core.jdbc.JdbcService)

Example 23 with JdbcConnection

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;
}
Also used : JdbcConnection(com.adaptris.core.jdbc.JdbcConnection)

Example 24 with JdbcConnection

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;
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) JdbcConnection(com.adaptris.core.jdbc.JdbcConnection)

Example 25 with JdbcConnection

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;
}
Also used : JdbcConnection(com.adaptris.core.jdbc.JdbcConnection)

Aggregations

JdbcConnection (com.adaptris.core.jdbc.JdbcConnection)30 TimeInterval (com.adaptris.util.TimeInterval)6 Test (org.junit.Test)6 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)4 BinaryStreamStatementParameter (com.adaptris.core.services.jdbc.BinaryStreamStatementParameter)3 BytePayloadStatementParameter (com.adaptris.core.services.jdbc.BytePayloadStatementParameter)3 CharacterStreamStatementParameter (com.adaptris.core.services.jdbc.CharacterStreamStatementParameter)3 DateStatementParameter (com.adaptris.core.services.jdbc.DateStatementParameter)3 StatementParameter (com.adaptris.core.services.jdbc.StatementParameter)3 TimeStatementParameter (com.adaptris.core.services.jdbc.TimeStatementParameter)3 TimestampStatementParameter (com.adaptris.core.services.jdbc.TimestampStatementParameter)3 SimpleDateFormat (java.text.SimpleDateFormat)3 ServiceException (com.adaptris.core.ServiceException)2 JdbcService (com.adaptris.core.jdbc.JdbcService)2 KeyValuePair (com.adaptris.util.KeyValuePair)2 KeyValuePairSet (com.adaptris.util.KeyValuePairSet)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 CoreException (com.adaptris.core.CoreException)1 XStreamMarshaller (com.adaptris.core.XStreamMarshaller)1