Package org.sql2o

Examples of org.sql2o.Sql2o


        org.h2.jdbcx.JdbcDataSource ds = new org.h2.jdbcx.JdbcDataSource();
        ds.setURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
        ds.setUser("sa");
        ds.setPassword("");

        Sql2o sql2o = new Sql2o(ds, new NoQuirks(new HashMap<Class, Converter>() {{
            put(DateTime.class, new DateTimeConverter(DateTimeZone.getDefault()));
        }}));

        assertThat(sql2o.getQuirks(), is(instanceOf(NoQuirks.class)));

        try (Connection connection = sql2o.open()) {
            int val = connection.createQuery("select 42").executeScalar(Integer.class);

            assertThat(val, is(equalTo(42)));
        }
    }
View Full Code Here


            } catch (SQLException e) {
                throw new RuntimeException("could not register driver '" + driverToRegister.getClass().getName() + "'", e);
            }
        }

        this.sql2o = new Sql2o(url, user, pass);

        this.url = url;
        this.user = user;
        this.pass = pass;
View Full Code Here

     * Comment:
     * The priority was wrong. Sql2o would try to set the field first, and afterwards the setter. The priority should be
     * the setter first and the field after.
     */
    @Test public void testSetterPriority(){
        Sql2o sql2o = new Sql2o(url, user, pass);
        Issue1Pojo pojo = sql2o.createQuery("select 1 val from (values(0))").executeAndFetchFirst(Issue1Pojo.class);

        assertEquals(2, pojo.val);

    }
View Full Code Here

     *
     *  Issue: NPE - should instead tell what the problem is
     *
     */
    @Test public void testForFieldDoesNotExistException(){
        Sql2o sql2o = new Sql2o(url, user, pass);


        try{
            KeyValueEntity pojo = sql2o.createQuery("select 1 id, 'something' foo from (values(0))").executeAndFetchFirst(KeyValueEntity.class);
        }
        catch(Sql2oException ex){
            assertTrue(ex.getMessage().contains("Could not map"));
        }
    }
View Full Code Here

            DriverManager.registerDriver((Driver)oracleDriverClass.newInstance());
        } catch (Throwable t) {
            throw new RuntimeException(t);
        }

        this.sql2o = new Sql2o("jdbc:oracle:thin:@//localhost:1521/orcl", "test", "test");
    }
View Full Code Here

    @Before
    public void setup() {
        Logger.getLogger("org.hibernate").setLevel(Level.OFF);

        sql2o = new Sql2o(DB_URL, DB_USER, DB_PASSWORD);

        createPostTable();

        // turn off oracle because ResultSetUtils slows down with oracle
        setOracleAvailable(false);
View Full Code Here

    public PostgresTest(String url, String user, String pass, String testName) {

        logger.info(testName);

        sql2o = new Sql2o(url, user, pass, new PostgresQuirks(){
            {
                // make sure we use default UUID converter.
                converters.put(UUID.class, new UUIDConverter());
            }
        });
View Full Code Here

TOP

Related Classes of org.sql2o.Sql2o

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.