Example usage for org.apache.ibatis.datasource.pooled PooledDataSource getDriver

List of usage examples for org.apache.ibatis.datasource.pooled PooledDataSource getDriver

Introduction

In this page you can find the example usage for org.apache.ibatis.datasource.pooled PooledDataSource getDriver.

Prototype

public String getDriver() 

Source Link

Usage

From source file:com.websys.crm.AddressTests.java

License:Open Source License

@Test
public void loadConfig() {

    LOG.debug("Executing config loading test...");
    LOG.debug("DBCOnfig : " + dbConfig);

    try {/*from ww  w .  j a  va2s. com*/
        PooledDataSource dataSource = dbConfig.createPooledDataSource();
        LOG.debug("dataSource : " + dataSource.getDriver());

        Address address = addressService.getCustomerAddress(1);

        System.out.println(address);
        AddressType type = address.getTypeKey();
        System.out.println(type);

    } catch (Exception e) {
        e.printStackTrace();
    }

    LOG.debug("<-------  Finished Loading of Conifg  ------->");
}

From source file:com.websys.crm.CrmConfigurationTest.java

License:Open Source License

@Test
public void loadConfig() {

    LOG.debug("Executing config loading test...");
    LOG.debug("DBCOnfig : " + dbConfig);

    try {//from   w w  w .j a va2s .  co  m
        PooledDataSource dataSource = dbConfig.createPooledDataSource();
        LOG.debug("dataSource : " + dataSource.getDriver());

        Customer newCustomer = new Customer();
        newCustomer.setTypeKey(CustomerType.RESIDENTIAL);

        Address customerAddress = new Address();
        customerAddress.setStreetAddress1("209, 2-26 Wattle Crescent");
        customerAddress.setSuburb("Pyrmont");
        customerAddress.setStateKey("NSW");
        customerAddress.setPostcode("2009");
        customerAddress.setCountryKey("AU");
        customerAddress.setPublicAddressId("PAI_12345");
        customerAddress.setTypeKey(AddressType.BOTH);

        CustomerDetails customerDetails = new CustomerDetails();
        customerDetails.setFirstName("Ryan");
        customerDetails.setLastName("Gosling");
        customerDetails.setEmailId("madhur.mehta@msc.com");
        customerDetails.setGenderKey(GenderType.MALE);
        customerDetails.setTitleKey(TitleType.MR);

        User newUser = new User();

        ContactDetails contactDetails = new ContactDetails();
        contactDetails.setContactNumber("0481348082");
        contactDetails.setContactPreferenceKey(ContactPreference.SMS_EMAIL);
        contactDetails.setEmailId("madhur.mehta@msc.com");

        customerService.addCustomer(newCustomer, customerAddress, newUser, customerDetails, contactDetails);

        Customer customer = customerService.getCreated(newCustomer.getCustomerId());
        System.out.println(customer.getCreated());
        assertNotNull(customer);

    } catch (Exception e) {
        e.printStackTrace();
    }

    LOG.debug("<-------  Finished Loading of Conifg  ------->");

}

From source file:com.websys.crm.UsersTests.java

License:Open Source License

@Test
public void loadConfig() {

    LOG.debug("Executing config loading test...");
    LOG.debug("DBCOnfig : " + dbConfig);

    try {/*from w ww. ja v a 2  s  .c o  m*/
        PooledDataSource dataSource = dbConfig.createPooledDataSource();
        LOG.debug("dataSource : " + dataSource.getDriver());

        // User user = new User();
        // user.setCustomerId(1);
        // user.setUsername("madz_3");
        // user.setPassword("qwerty");
        // user.setUserType(UserType.USER);
        //
        // userService.addUser(user);
        //
        // System.out.println(user.getChanged());
        // assertNotNull(user);

        User user = userService.retrieveByUsername("madz_2");
        System.out.println(user);

    } catch (Exception e) {
        e.printStackTrace();
    }

    LOG.debug("<-------  Finished Loading of Conifg  ------->");
}

From source file:com.websys.offer.OfferConfigurationTest.java

License:Open Source License

public void testAddOffer() {

    LOG.debug("DBCOnfig : " + dbConfig);

    try {/*from  w  w  w .  ja  v a2  s  .  co  m*/
        PooledDataSource dataSource = dbConfig.createPooledDataSource();
        LOG.debug("dataSource : " + dataSource.getDriver());

        Offer newOffer = new Offer();
        newOffer.setOfferData("{}");
        newOffer.setTypeKey(OfferType.BASE_OFFER);
        offerService.addOffer(newOffer);

        newOffer = offerService.retrieveOfferByOfferId(newOffer.getOfferId());

        OfferMapping offerMapping = new OfferMapping();
        offerMapping.setCustomerId(1);
        offerMapping.setOfferId(newOffer.getOfferId());
        offerService.addOfferMapping(offerMapping);

        List<OfferMapping> list = offerService.retrieveOfferListByCustomerId(offerMapping.getCustomerId());

        System.out.println(newOffer.getChanged() + " " + offerMapping.getCustomerId() + " " + list.size());
        assertNotNull(newOffer);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.websys.offer.OfferConfigurationTest.java

License:Open Source License

@Test
public void testUpdateValidTo() {

    LOG.debug("DBCOnfig : " + dbConfig);

    try {/*w w w.  j a v a 2 s.co  m*/
        PooledDataSource dataSource = dbConfig.createPooledDataSource();
        LOG.debug("dataSource : " + dataSource.getDriver());

        offerService.offerStatusCompleted(1);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.websys.order.OrderConfigurationTest.java

License:Open Source License

public void testAddOrder() {

    LOG.debug("DBCOnfig : " + dbConfig);

    try {/*from  w w w  .  j a  v a 2 s  . c  om*/
        PooledDataSource dataSource = dbConfig.createPooledDataSource();
        LOG.debug("dataSource : " + dataSource.getDriver());

        Order newOrder = new Order();
        newOrder.setOrderData("{}");
        newOrder.setOrderType(OrderType.CREATE_NEW_CUSTOMER.name());
        orderService.addOrder(newOrder);

        newOrder = orderService.retrieveOrderByOrderId(newOrder.getOrderId());

        OrderMapping orderMapping = new OrderMapping();
        orderMapping.setCustomerId(1);
        orderMapping.setOrderId(newOrder.getOrderId());
        orderService.addOrderMapping(orderMapping);

        orderService.retrieveOrderListByCustomerId(orderMapping.getCustomerId());

        System.out.println(newOrder.getChanged() + " " + orderMapping.getCustomerId());
        assertNotNull(newOrder);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.websys.order.OrderConfigurationTest.java

License:Open Source License

public void testUpdateValidTo() {

    LOG.debug("DBCOnfig : " + dbConfig);

    try {/*w ww .  j ava  2s  .com*/
        PooledDataSource dataSource = dbConfig.createPooledDataSource();
        LOG.debug("dataSource : " + dataSource.getDriver());

        orderService.orderStatusCompleted(2);

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.mybatis.guice.datasource.builtin.PooledDataSourceProviderTest.java

License:Apache License

@Test
public void get() throws Throwable {
    final String driver = "org.mybatis.guice.TestDriver";
    final String url = "jdbc:h2:mem:testdb";
    final String username = "test_user";
    final String password = "test_password";
    final boolean autoCommit = true;
    final int loginTimeout = 10;
    final Properties driverProperties = new Properties();
    driverProperties.setProperty("my_property", "true");
    final int maximumActiveConnections = 20;
    final int maximumCheckoutTime = 30;
    final int maximumIdleConnections = 40;
    final int pingConnectionsNotUsedFor = 50;
    final boolean pingEnabled = true;
    final String pingQuery = "SELECT 1";
    final int timeToWait = 60;
    Injector injector = Guice.createInjector(new AbstractModule() {
        @Override/*  w ww.j av  a2  s . c  o  m*/
        protected void configure() {
            bind(ClassLoader.class).annotatedWith(Names.named("JDBC.driverClassLoader"))
                    .toInstance(driverClassLoader);
            bindConstant().annotatedWith(Names.named("JDBC.driver")).to(driver);
            bindConstant().annotatedWith(Names.named("JDBC.url")).to(url);
            bindConstant().annotatedWith(Names.named("JDBC.username")).to(username);
            bindConstant().annotatedWith(Names.named("JDBC.password")).to(password);
            bindConstant().annotatedWith(Names.named("JDBC.autoCommit")).to(autoCommit);
            bindConstant().annotatedWith(Names.named("JDBC.loginTimeout")).to(loginTimeout);
            bind(Properties.class).annotatedWith(Names.named("JDBC.driverProperties"))
                    .toInstance(driverProperties);
            bindConstant().annotatedWith(Names.named("mybatis.pooled.maximumActiveConnections"))
                    .to(maximumActiveConnections);
            bindConstant().annotatedWith(Names.named("mybatis.pooled.maximumCheckoutTime"))
                    .to(maximumCheckoutTime);
            bindConstant().annotatedWith(Names.named("mybatis.pooled.maximumIdleConnections"))
                    .to(maximumIdleConnections);
            bindConstant().annotatedWith(Names.named("mybatis.pooled.pingConnectionsNotUsedFor"))
                    .to(pingConnectionsNotUsedFor);
            bindConstant().annotatedWith(Names.named("mybatis.pooled.pingEnabled")).to(pingEnabled);
            bindConstant().annotatedWith(Names.named("mybatis.pooled.pingQuery")).to(pingQuery);
            bindConstant().annotatedWith(Names.named("mybatis.pooled.timeToWait")).to(timeToWait);
        }
    });
    PooledDataSourceProvider provider = injector.getInstance(PooledDataSourceProvider.class);

    PooledDataSource dataSource = (PooledDataSource) provider.get();

    assertEquals(driver, dataSource.getDriver());
    assertEquals(url, dataSource.getUrl());
    assertEquals(username, dataSource.getUsername());
    assertEquals(password, dataSource.getPassword());
    assertEquals(autoCommit, dataSource.isAutoCommit());
    assertEquals(loginTimeout, dataSource.getLoginTimeout());
    assertEquals(driverProperties, dataSource.getDriverProperties());
    assertEquals(maximumActiveConnections, dataSource.getPoolMaximumActiveConnections());
    assertEquals(maximumCheckoutTime, dataSource.getPoolMaximumCheckoutTime());
    assertEquals(maximumIdleConnections, dataSource.getPoolMaximumIdleConnections());
    assertEquals(pingConnectionsNotUsedFor, dataSource.getPoolPingConnectionsNotUsedFor());
    assertEquals(pingEnabled, dataSource.isPoolPingEnabled());
    assertEquals(pingQuery, dataSource.getPoolPingQuery());
    assertEquals(timeToWait, dataSource.getPoolTimeToWait());
}

From source file:org.mybatis.guice.datasource.builtin.PooledDataSourceProviderTest.java

License:Apache License

@Test
public void get_OtherValues() throws Throwable {
    final String driver = "org.mybatis.guice.TestDriver2";
    final String url = "jdbc:h2:mem:testdb2";
    final String username = "test_user2";
    final String password = "test_password2";
    final boolean autoCommit = false;
    final int loginTimeout = 11;
    final Properties driverProperties = new Properties();
    driverProperties.setProperty("my_property", "false");
    final int maximumActiveConnections = 21;
    final int maximumCheckoutTime = 31;
    final int maximumIdleConnections = 41;
    final int pingConnectionsNotUsedFor = 51;
    final boolean pingEnabled = false;
    final String pingQuery = "SELECT 1";
    final int timeToWait = 61;
    Injector injector = Guice.createInjector(new AbstractModule() {
        @Override/*from w ww .  ja  v a 2s. c  o  m*/
        protected void configure() {
            bind(ClassLoader.class).annotatedWith(Names.named("JDBC.driverClassLoader"))
                    .toInstance(driverClassLoader);
            bindConstant().annotatedWith(Names.named("JDBC.driver")).to(driver);
            bindConstant().annotatedWith(Names.named("JDBC.url")).to(url);
            bindConstant().annotatedWith(Names.named("JDBC.username")).to(username);
            bindConstant().annotatedWith(Names.named("JDBC.password")).to(password);
            bindConstant().annotatedWith(Names.named("JDBC.autoCommit")).to(autoCommit);
            bindConstant().annotatedWith(Names.named("JDBC.loginTimeout")).to(loginTimeout);
            bind(Properties.class).annotatedWith(Names.named("JDBC.driverProperties"))
                    .toInstance(driverProperties);
            bindConstant().annotatedWith(Names.named("mybatis.pooled.maximumActiveConnections"))
                    .to(maximumActiveConnections);
            bindConstant().annotatedWith(Names.named("mybatis.pooled.maximumCheckoutTime"))
                    .to(maximumCheckoutTime);
            bindConstant().annotatedWith(Names.named("mybatis.pooled.maximumIdleConnections"))
                    .to(maximumIdleConnections);
            bindConstant().annotatedWith(Names.named("mybatis.pooled.pingConnectionsNotUsedFor"))
                    .to(pingConnectionsNotUsedFor);
            bindConstant().annotatedWith(Names.named("mybatis.pooled.pingEnabled")).to(pingEnabled);
            bindConstant().annotatedWith(Names.named("mybatis.pooled.pingQuery")).to(pingQuery);
            bindConstant().annotatedWith(Names.named("mybatis.pooled.timeToWait")).to(timeToWait);
        }
    });
    PooledDataSourceProvider provider = injector.getInstance(PooledDataSourceProvider.class);

    PooledDataSource dataSource = (PooledDataSource) provider.get();

    assertEquals(driver, dataSource.getDriver());
    assertEquals(url, dataSource.getUrl());
    assertEquals(username, dataSource.getUsername());
    assertEquals(password, dataSource.getPassword());
    assertEquals(autoCommit, dataSource.isAutoCommit());
    assertEquals(loginTimeout, dataSource.getLoginTimeout());
    assertEquals(driverProperties, dataSource.getDriverProperties());
    assertEquals(maximumActiveConnections, dataSource.getPoolMaximumActiveConnections());
    assertEquals(maximumCheckoutTime, dataSource.getPoolMaximumCheckoutTime());
    assertEquals(maximumIdleConnections, dataSource.getPoolMaximumIdleConnections());
    assertEquals(pingConnectionsNotUsedFor, dataSource.getPoolPingConnectionsNotUsedFor());
    assertEquals(pingEnabled, dataSource.isPoolPingEnabled());
    assertEquals(pingQuery, dataSource.getPoolPingQuery());
    assertEquals(timeToWait, dataSource.getPoolTimeToWait());
}