Search in sources :

Example 1 with ExecuteQueryCallableStatementExecutor

use of com.adaptris.jdbc.ExecuteQueryCallableStatementExecutor in project interlok by adaptris.

the class StoredProcedureProducerTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    JdbcStoredProcedureProducer exampleProducer = new JdbcStoredProcedureProducer();
    exampleProducer.setStatementCreator(new MysqlStatementCreator());
    exampleProducer.setStatementExecutor(new ExecuteQueryCallableStatementExecutor());
    exampleProducer.setProcedureName("The Stored Procedure to call");
    TimeInterval timeout = new TimeInterval(10L, TimeUnit.SECONDS);
    exampleProducer.setTimeout(timeout);
    JdbcConnection jdbcConnection = new JdbcConnection("jdbc:mysql://localhost:3306/mydatabase", "com.mysql.jdbc.Driver");
    jdbcConnection.setUsername("optional_username");
    jdbcConnection.setPassword("optional_password");
    exampleProducer.setResultSetTranslator(new XmlPayloadTranslator());
    JdbcMetadataParameter inMetaParameter = new JdbcMetadataParameter();
    inMetaParameter.setMetadataKey("InParam1MetaKey");
    inMetaParameter.setName("InParam1");
    inMetaParameter.setType(ParameterValueType.VARCHAR);
    inMetaParameter.setOrder(5);
    JdbcObjectMetadataParameter inObjectParameter = new JdbcObjectMetadataParameter();
    inObjectParameter.setMetadataKey("InParam2MetaKey");
    inObjectParameter.setName("InParam2");
    inObjectParameter.setType(ParameterValueType.INTEGER);
    inObjectParameter.setOrder(6);
    JdbcXPathParameter inXPathParameter = new JdbcXPathParameter();
    inXPathParameter.setName("InParam3");
    inXPathParameter.setType(ParameterValueType.VARCHAR);
    inXPathParameter.setXpath("/some/xpath");
    inXPathParameter.setOrder(7);
    JdbcConstantParameter inConstantParameter = new JdbcConstantParameter();
    inConstantParameter.setConstant("InParam4Value");
    inConstantParameter.setName("InParam4");
    inConstantParameter.setType(ParameterValueType.VARCHAR);
    inConstantParameter.setOrder(8);
    JdbcStringPayloadParameter inPayloadParameter = new JdbcStringPayloadParameter();
    inPayloadParameter.setName("InParam4");
    inPayloadParameter.setType(ParameterValueType.CLOB);
    inPayloadParameter.setOrder(9);
    JdbcBytePayloadParameter inBytePayloadParameter = new JdbcBytePayloadParameter();
    inBytePayloadParameter.setName("InParam5");
    inBytePayloadParameter.setType(ParameterValueType.BLOB);
    inBytePayloadParameter.setOrder(10);
    JdbcMetadataParameter outMetaParameter = new JdbcMetadataParameter();
    outMetaParameter.setMetadataKey("OutParam1MetaKey");
    outMetaParameter.setName("OutParam1");
    outMetaParameter.setType(ParameterValueType.VARCHAR);
    outMetaParameter.setOrder(1);
    JdbcObjectMetadataParameter outObjectParameter = new JdbcObjectMetadataParameter();
    outObjectParameter.setMetadataKey("OutParam2MetaKey");
    outObjectParameter.setName("OutParam2");
    outObjectParameter.setType(ParameterValueType.BLOB);
    outObjectParameter.setOrder(2);
    JdbcMetadataParameter inOutMetaParameter = new JdbcMetadataParameter();
    inOutMetaParameter.setMetadataKey("InOutParam1MetaKey");
    inOutMetaParameter.setName("InOutParam1");
    inOutMetaParameter.setType(ParameterValueType.VARCHAR);
    inOutMetaParameter.setOrder(3);
    JdbcObjectMetadataParameter inOutObjectParameter = new JdbcObjectMetadataParameter();
    inOutObjectParameter.setMetadataKey("InOutParam2MetaKey");
    inOutObjectParameter.setName("InOutParam2");
    inOutObjectParameter.setType(ParameterValueType.VARCHAR);
    inOutObjectParameter.setOrder(4);
    InParameters inParams = new InParameters();
    inParams.add(inMetaParameter);
    inParams.add(inObjectParameter);
    inParams.add(inXPathParameter);
    inParams.add(inConstantParameter);
    inParams.add(inPayloadParameter);
    inParams.add(inBytePayloadParameter);
    OutParameters outParams = new OutParameters();
    outParams.add(outMetaParameter);
    outParams.add(outObjectParameter);
    InOutParameters inOutParams = new InOutParameters();
    inOutParams.add(inOutMetaParameter);
    inOutParams.add(inOutObjectParameter);
    exampleProducer.setInParameters(inParams);
    exampleProducer.setOutParameters(outParams);
    exampleProducer.setInOutParameters(inOutParams);
    return new StandaloneProducer(jdbcConnection, exampleProducer);
}
Also used : MysqlStatementCreator(com.adaptris.jdbc.MysqlStatementCreator) TimeInterval(com.adaptris.util.TimeInterval) XmlPayloadTranslator(com.adaptris.core.services.jdbc.XmlPayloadTranslator) ExecuteQueryCallableStatementExecutor(com.adaptris.jdbc.ExecuteQueryCallableStatementExecutor) StandaloneProducer(com.adaptris.core.StandaloneProducer)

Aggregations

StandaloneProducer (com.adaptris.core.StandaloneProducer)1 XmlPayloadTranslator (com.adaptris.core.services.jdbc.XmlPayloadTranslator)1 ExecuteQueryCallableStatementExecutor (com.adaptris.jdbc.ExecuteQueryCallableStatementExecutor)1 MysqlStatementCreator (com.adaptris.jdbc.MysqlStatementCreator)1 TimeInterval (com.adaptris.util.TimeInterval)1