use of com.adaptris.jdbc.MysqlStatementCreator in project interlok by adaptris.
the class StoredProcedureProducerTest method configureForTests.
private StandaloneProducer configureForTests(JdbcStoredProcedureProducer p, boolean addConnection) {
if (PROPERTIES.getProperty(JDBC_VENDOR).equals("mysql"))
p.setStatementCreator(new MysqlStatementCreator());
else if (PROPERTIES.getProperty(JDBC_VENDOR).equals("sqlserver"))
p.setStatementCreator(new SqlServerStatementCreator());
else
fail("Vendor for JDBC tests unknown: " + PROPERTIES.getProperty(JDBC_VENDOR));
if (addConnection) {
JdbcConnection jdbcConnection = new JdbcConnection(PROPERTIES.getProperty(JDBC_URL), PROPERTIES.getProperty(JDBC_DRIVER));
jdbcConnection.setUsername(PROPERTIES.getProperty(JDBC_USER));
jdbcConnection.setPassword(PROPERTIES.getProperty(JDBC_PASSWORD));
return new StandaloneProducer(jdbcConnection, p);
}
return new StandaloneProducer(p);
}
use of com.adaptris.jdbc.MysqlStatementCreator in project interlok by adaptris.
the class StoredProcedureProducerTest method testConnectionInObjectMetadata.
@Test
public void testConnectionInObjectMetadata() throws Exception {
JdbcServiceList serviceList = new JdbcServiceList();
try {
if (areTestsEnabled()) {
JdbcConnection jdbcConnection = new JdbcConnection(PROPERTIES.getProperty(JDBC_URL), PROPERTIES.getProperty(JDBC_DRIVER));
jdbcConnection.setUsername(PROPERTIES.getProperty(JDBC_USER));
jdbcConnection.setPassword(PROPERTIES.getProperty(JDBC_PASSWORD));
serviceList.setConnection(jdbcConnection);
JdbcStoredProcedureProducer myStoredProc = new JdbcStoredProcedureProducer();
if (PROPERTIES.getProperty(JDBC_VENDOR).equals("mysql"))
myStoredProc.setStatementCreator(new MysqlStatementCreator());
else if (PROPERTIES.getProperty(JDBC_VENDOR).equals("sqlserver"))
myStoredProc.setStatementCreator(new SqlServerStatementCreator());
myStoredProc.setProcedureName(("one_in_one_out"));
serviceList.add(new StandaloneProducer(myStoredProc));
start(serviceList);
AdaptrisMessage message = createMessage(XML_PAYLOAD);
AdaptrisMessage message2 = createMessage(XML_PAYLOAD);
JdbcXPathParameter inParameter = new JdbcXPathParameter();
inParameter.setXpath("/head/body/element1");
inParameter.setName("xType");
inParameter.setType(ParameterValueType.VARCHAR);
InParameters inParameters = new InParameters();
inParameters.add(inParameter);
JdbcMetadataParameter outParameter = new JdbcMetadataParameter();
outParameter.setMetadataKey("result");
outParameter.setName("transferCount");
outParameter.setType(ParameterValueType.INTEGER);
OutParameters outParameters = new OutParameters();
outParameters.add(outParameter);
myStoredProc.setInParameters(inParameters);
myStoredProc.setOutParameters(outParameters);
assertEquals(0, message.getMetadata().size());
serviceList.doService(message);
assertEquals("15", message.getMetadataValue("result"));
assertEquals(0, message2.getMetadata().size());
serviceList.doService(message2);
assertEquals("15", message2.getMetadataValue("result"));
}
} finally {
stop(serviceList);
}
}
use of com.adaptris.jdbc.MysqlStatementCreator 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);
}
Aggregations