Package org.apache.commons.dbutils

Examples of org.apache.commons.dbutils.QueryRunner


            {
                queryRunner = new ExtendedQueryRunner(dataSource, this.queryTimeout);
            }
            else
            {
                queryRunner = new QueryRunner();
            }
        }
    }
View Full Code Here


    @Override
    protected void createTable() throws Exception
    {
        super.createTable();
        QueryRunner qr = jdbcConnector.getQueryRunner();
        qr.update(jdbcConnector.getConnection(), "CREATE TABLE IDS(K VARCHAR(255) NOT NULL PRIMARY KEY, VALUE VARCHAR(255))");
    }
View Full Code Here

    @Override
    protected void deleteTable() throws Exception
    {
        super.deleteTable();
        QueryRunner qr = jdbcConnector.getQueryRunner();
        qr.update(jdbcConnector.getConnection(), "DELETE FROM IDS");
    }
View Full Code Here

    {
        MuleClient client = new MuleClient(muleContext);
        MuleMessage message = client.request("jdbc://SELECT * FROM TEST", 1000);
        assertResultSetEmpty(message);
       
        QueryRunner qr = jdbcConnector.getQueryRunner();
        int updated = qr.update(jdbcConnector.getConnection(), "INSERT INTO TEST(TYPE, DATA) VALUES (1, '" + TEST_MESSAGE + "')");
        assertEquals(1, updated);
        message = client.request("jdbc://SELECT * FROM TEST", 1000);
        assertResultSetNotEmpty(message);
    }
View Full Code Here

    public void testSend() throws Exception
    {
        MuleClient client = new MuleClient(muleContext);
        client.send("jdbc://writeTest?type=2", new DefaultMuleMessage(TEST_MESSAGE, muleContext));

        QueryRunner qr = jdbcConnector.getQueryRunner();
        Object[] obj2 =
            (Object[]) qr.query(jdbcConnector.getConnection(), "SELECT DATA FROM TEST WHERE TYPE = 2", new ArrayHandler());
        assertNotNull(obj2);
        assertEquals(1, obj2.length);
        assertEquals(TEST_MESSAGE, obj2[0]);
    }
View Full Code Here

        MuleClient client = new MuleClient(muleContext);
        Map map = new HashMap();
        map.put("data", TEST_MESSAGE);
        client.send("jdbc://writeMap?type=2", new DefaultMuleMessage(map, muleContext));

        QueryRunner qr = jdbcConnector.getQueryRunner();
        Object[] obj2 =
            (Object[]) qr.query(jdbcConnector.getConnection(), "SELECT DATA FROM TEST WHERE TYPE = 2", new ArrayHandler());
        assertNotNull(obj2);
        assertEquals(1, obj2.length);
        assertEquals(TEST_MESSAGE, obj2[0]);
    }
View Full Code Here

    {
        MuleClient client = new MuleClient(muleContext);
        MuleMessage message = client.request("jdbc://getTest?type=1", 1000);
        assertResultSetEmpty(message);

        QueryRunner qr = jdbcConnector.getQueryRunner();
        int updated = qr.update(jdbcConnector.getConnection(), "INSERT INTO TEST(TYPE, DATA, ACK, RESULT) VALUES (1, '" + TEST_MESSAGE
            + "', NULL, NULL)");
        assertEquals(1, updated);

        message = client.request("jdbc://getTest?type=1", 1000);
        assertResultSetNotEmpty(message);
View Full Code Here

        assertResultSetNotEmpty(message);
    }

    public void testReceiveAndSend() throws Exception
    {
        QueryRunner qr = jdbcConnector.getQueryRunner();
        qr.update(jdbcConnector.getConnection(),
            "INSERT INTO TEST(TYPE, DATA, ACK, RESULT) VALUES (1, '" + TEST_MESSAGE + "', NULL, NULL)");

        long t0 = System.currentTimeMillis();
        while (System.currentTimeMillis() - t0 < 20000)
        {
            Object[] rs =
                (Object[]) qr.query(jdbcConnector.getConnection(), "SELECT COUNT(*) FROM TEST WHERE TYPE = 2", new ArrayHandler());
            assertNotNull(rs);
            assertEquals(1, rs.length);
            if (((Number)rs[0]).intValue() > 0)
            {
                break;
            }
            Thread.sleep(100);
        }

        Object[] obj2 =
            (Object[]) qr.query(jdbcConnector.getConnection(), "SELECT DATA FROM TEST WHERE TYPE = 2", new ArrayHandler());
        assertNotNull(obj2);
        assertEquals(1, obj2.length);
        assertEquals(TEST_MESSAGE + " Received", obj2[0]);
    }
View Full Code Here

        doTestBridge();
    }
       
    protected void doTestBridge() throws Exception
    {
        QueryRunner queryRunner = jdbcConnector.getQueryRunner();
        Connection connection = jdbcConnector.getConnection();

        for (int i = 0; i < TEST_ROWS; i++)
        {
            queryRunner.update(connection, "INSERT INTO TEST(TYPE, DATA) VALUES (1, 'Test " + i + "')");
        }
        List<?> results = (List<?>) queryRunner.query(connection, "SELECT * FROM TEST WHERE TYPE = 1", new ArrayListHandler());
        assertEquals(TEST_ROWS, results.size());

        long t0 = System.currentTimeMillis();
        while (true)
        {
            results = (List<?>) queryRunner.query(connection, "SELECT * FROM TEST_OUT", new ArrayListHandler());
            logger.info("Results found: " + results.size());
            if (results.size() >= TEST_ROWS)
            {
                break;
            }
            results = (List<?>) queryRunner.query(connection, "SELECT * FROM TEST WHERE TYPE = 2", new ArrayListHandler());
            logger.info("Locked records found: " + results.size());
            assertTrue(TEST_ROWS >= results.size());           
           
            results = (List<?>) queryRunner.query(connection, "SELECT * FROM TEST WHERE TYPE = 1", new ArrayListHandler());
            logger.info("Original records found: " + results.size());
            assertTrue(TEST_ROWS >= results.size());
           
            assertTrue(System.currentTimeMillis() - t0 < 20000);
            Thread.sleep(500);
View Full Code Here

      currentVersion.setVersion("2.1.2");
    }

    if (currentVersion.between("2.1.2", "2.1.3"))
    {
      List<Map<String, ?>> res = (List<Map<String, ?>>) new QueryRunner().query(connection,
              "SELECT id, colorscheme FROM aktariouserpreferences", new MapListHandler());

      for (Map<String, ?> row : res)
      {
        update("UPDATE aktariouserpreferences set colorscheme = ? where id = ?", new Object[]
View Full Code Here

TOP

Related Classes of org.apache.commons.dbutils.QueryRunner

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.