Package org.mule.module.db.internal.domain.connection

Examples of org.mule.module.db.internal.domain.connection.DbConnection


    }

    @Override
    public MuleEvent process(MuleEvent muleEvent) throws MuleException
    {
        DbConnection connection = null;

        DbConfig dbConfig = dbConfigResolver.resolve(muleEvent);

        try
        {
View Full Code Here


        }
    }

    private Result<MetaData> getMetaDataResult(Query query, MetadataResolver metadataResolver)
    {
        DbConnection connection = null;

        DbConfig dbConfig = dbConfigResolver.resolve(null);

        try
        {
            try
            {
                connection = dbConfig.getConnectionFactory().createConnection(TransactionalAction.NOT_SUPPORTED);
            }
            catch (SQLException e)
            {
                return new DefaultResult<MetaData>(null, Result.Status.FAILURE, e.getMessage(), FailureType.CONNECTION_FAILURE, e);
            }

            PreparedStatement preparedStatement;
            try
            {
                preparedStatement = connection.prepareStatement(query.getQueryTemplate().getSqlText());
            }
            catch (SQLException e)
            {
                return new DefaultResult<MetaData>(null, Result.Status.FAILURE, e.getMessage(), FailureType.INVALID_CONFIGURATION, e);
            }
View Full Code Here

        List<QueryParamValue> resolvedParams = Collections.singletonList(new QueryParamValue("param1", "foo"));
        when(paramValueResolver.resolveParams(muleEvent, unresolvedTemplateQuery.getParamValues())).thenReturn(resolvedParams);

        QueryResolver queryResolver = new ParametrizedQueryResolver(unresolvedTemplateQuery, paramValueResolver);

        DbConnection connection = mock(DbConnection.class);
        when(connection.getParamTypes(unresolvedTemplateQuery.getQueryTemplate())).thenReturn(Collections.singletonMap(1, JdbcTypes.INTEGER_DB_TYPE));

        Query resolvedQuery = queryResolver.resolve(connection, muleEvent);

        assertThat(unresolvedTemplateQuery, not(sameInstance(resolvedQuery)));
        assertThat(unresolvedTemplateQuery.getQueryTemplate().getSqlText(), equalTo(resolvedQuery.getQueryTemplate().getSqlText()));
View Full Code Here

    public static final String SQL_TEXT = "select * from test where id = ?";

    @Test
    public void resolvesQueryParameterKnownType() throws Exception
    {
        DbConnection connection = createDbConnection();

        DbTypeManager dbTypeManager = new DbTypeManagerBuilder().on(connection).managing(JdbcTypes.INTEGER_DB_TYPE).build();

        QueryTemplate queryTemplate = createQueryTemplate();

View Full Code Here

    }

    @Test
    public void resolvesQueryParameterUnknownType() throws Exception
    {
        DbConnection connection = createDbConnection();

        QueryTemplate queryTemplate = createQueryTemplate();

        DbTypeManager dbTypeManager = new DbTypeManagerBuilder().on(connection).unknowing(JdbcTypes.INTEGER_DB_TYPE).build();
View Full Code Here

        ResultSet procedureColumns = new StoredProcedureColumnTypesBuilder().with(TestDbTypeMetadata.INTEGER_DB_TYPE_METADATA).build();
        DatabaseMetaData databaseMetaData = new DatabaseMetaDataBuilder().returningStoredProcedureColumns(catalog, "testStoredProcedure", procedureColumns).build();

        final String sqlText = "call testStoredProcedure(?)";

        DbConnection connection = new DbConnectionBuilder().onCalatog(catalog).with(databaseMetaData).build();

        QueryTemplate queryTemplate = new QueryTemplate(sqlText, QueryType.STORE_PROCEDURE_CALL, Collections.<org.mule.module.db.internal.domain.param.QueryParam>singletonList(new DefaultInputQueryParam(1, UnknownDbType.getInstance(), "7", TYPE_COLUMN)));

        DbTypeManager dbTypeManager = new DbTypeManagerBuilder().on(connection).managing(JdbcTypes.INTEGER_DB_TYPE).build();
View Full Code Here

    }

    @Test
    public void testCommitsWorkIfNoTransactionDefined() throws Exception
    {
        DbConnection connection = mock(DbConnection.class);
        DbConnectionFactory dbConnectionFactory = mock(DbConnectionFactory.class);
        when(dbConnectionFactory.createConnection(TransactionalAction.JOIN_IF_POSSIBLE)).thenReturn(connection);
        SelectExecutor selectExecutor = mock(SelectExecutor.class);

        SelectMessageProcessor processor = new SelectMessageProcessor(null, null, null, null, false);
View Full Code Here

    }

    @Test
    public void testCommitsWorkIfNoTransactionDefined() throws Exception
    {
        DbConnection connection = mock(DbConnection.class);
        DbConnectionFactory dbConnectionFactory = mock(DbConnectionFactory.class);
        when(dbConnectionFactory.createConnection(TransactionalAction.JOIN_IF_POSSIBLE)).thenReturn(connection);
        QueryExecutor updateExecutor = mock(QueryExecutor.class);

        UpdateMessageProcessor processor = new UpdateMessageProcessor(null, null, null, null, null);
View Full Code Here

    public void resolvesCustomDbTypes() throws Exception
    {
        GenericDbConfig dbConfig = muleContext.getRegistry().lookupObject("dbConfig");
        DbTypeManager dbTypeManager = dbConfig.getDbTypeManager();
        DbConnectionFactory connectionFactory = dbConfig.getConnectionFactory();
        DbConnection connection = connectionFactory.createConnection(TransactionalAction.NOT_SUPPORTED);

        try
        {
            assertResolvesType(connection, dbTypeManager, CUSTOM_TYPE_NAME1, CUSTOM_TYPE_ID1);
            assertResolvesType(connection, dbTypeManager, CUSTOM_TYPE_NAME2, CUSTOM_TYPE_ID2);
View Full Code Here

    public void ignoreUserDefinedTypes() throws Exception
    {
        DatabaseMetaData metaData = mock(DatabaseMetaData.class);
        when(metaData.getTypeInfo()).thenReturn(createResultSetWithUserDefinedTypes());

        DbConnection connection = mock(DbConnection.class);
        when(connection.getMetaData()).thenReturn(metaData);

        MetadataDbTypeManager typeManager = new MetadataDbTypeManager();

        assertThat(typeManager.lookup(connection, UDT_OK.getId(), UDT_OK.getName()), instanceOf(DbType.class));
View Full Code Here

TOP

Related Classes of org.mule.module.db.internal.domain.connection.DbConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.