Package org.nutz.dao

Examples of org.nutz.dao.ConnCallback


    }

    @Test
    public void testTransLevel() {
        final int[] ls = new int[5];
        dao.run(new ConnCallback() {
            public void invoke(Connection conn) throws Exception {
                ls[0] = conn.getTransactionIsolation();
            }
        });
        Trans.exec(Connection.TRANSACTION_SERIALIZABLE, new Atom() {
            public void run() {
                dao.run(new ConnCallback() {
                    public void invoke(Connection conn) throws Exception {
                        ls[1] = conn.getTransactionIsolation();
                    }
                });
            }
        });
        dao.run(new ConnCallback() {
            public void invoke(Connection conn) throws Exception {
                ls[2] = conn.getTransactionIsolation();
            }
        });
        Trans.exec(Connection.TRANSACTION_READ_COMMITTED, new Atom() {
            public void run() {
                dao.run(new ConnCallback() {
                    public void invoke(Connection conn) throws Exception {
                        ls[3] = conn.getTransactionIsolation();
                    }
                });
            }
        });
        dao.run(new ConnCallback() {
            public void invoke(Connection conn) throws Exception {
                ls[4] = conn.getTransactionIsolation();
            }
        });
        assertEquals(Connection.TRANSACTION_SERIALIZABLE, ls[1]);
View Full Code Here


    @Test
    public void test_issue312() {
        Trans.exec(new Atom(){
            public void run() {
                final Connection[] conns = new Connection[2];
                dao.run(new ConnCallback() {
                    public void invoke(Connection conn) throws Exception {
                        conns[0] = conn;
                    }
                });
                dao.run(new ConnCallback() {
                    public void invoke(Connection conn) throws Exception {
                        conns[1] = conn;
                    }
                });
                //必然是同一个对象
View Full Code Here

        if (cnd != null)
            sql.append(" ").append(cnd.toSql(en));
        if (log.isDebugEnabled())
            log.debug(sql);
        final int[] ints = new int[1];
        dao.run(new ConnCallback() {
            public void invoke(Connection conn) throws Exception {
                PreparedStatement ps = conn.prepareStatement(sql.toString());
                try {
                    for (int i = 0; i < values.size(); i++)
                        adaptors.get(i).set(ps, values.get(i), i + 1);
View Full Code Here

        sql.append(")");
        _value_places.append(")");
        sql.append(_value_places);
        if (log.isDebugEnabled())
            log.debug(sql);
        dao.run(new ConnCallback() {
            public void invoke(Connection conn) throws Exception {
                PreparedStatement ps = conn.prepareStatement(sql.toString());
                try {
                    for (int i = 0; i < values.size(); i++)
                        adaptors.get(i).set(ps, values.get(i), i + 1);
View Full Code Here

    public void test_fastInsert_rollback_jdbc() {
        dao.create(Pet.class, true);
        try {
            Trans.exec(new Molecule<Object>() {
                public void run() {
                    dao.run(new ConnCallback() {
                        public void invoke(Connection conn) throws Exception {
                            PreparedStatement ps = conn.prepareStatement("INSERT INTO t_pet(name) VALUES(?)");
                            for (int i = 0; i < 100; i++) {
                                ps.setString(1, "XXXXX" + i);
                                ps.addBatch();
View Full Code Here

        synchronized (map) {
            map.put(classOfT, re);
        }
        support.expert.createEntity(dao, re);
        // 最后在数据库中验证一下实体各个字段
        support.run(new ConnCallback() {
            public void invoke(Connection conn) throws Exception {
                support.expert.setupEntityField(conn, re);
            }
        });
        return re;
View Full Code Here

            en.addMappingField(ef);
        }
        en.checkCompositeFields(null);

        // 最后在数据库中验证一下实体各个字段
        support.run(new ConnCallback() {
            public void invoke(Connection conn) throws Exception {
                support.expert.setupEntityField(conn, en);
            }
        });
View Full Code Here

        dataSource = ds;
        expert = Jdbcs.getExpert(ds);
        pojoMaker = new NutPojoMaker(expert);

        meta = new DatabaseMeta();
        runner.run(dataSource, new ConnCallback() {
            public void invoke(Connection conn) throws Exception {
                DatabaseMetaData dmd = conn.getMetaData();
                meta.setProductName(dmd.getDatabaseProductName());
                meta.setVersion(dmd.getDatabaseProductVersion());
                log.debug("JDBC Driver --> " + dmd.getDriverVersion());
View Full Code Here

        return exists(getEntity(classOfT).getViewName());
    }

    public boolean exists(final String tableName) {
        final boolean[] ee = {false};
        this.run(new ConnCallback() {
            public void invoke(Connection conn) {
                Statement stat = null;
                ResultSet rs = null;
                try {
                    stat = conn.createStatement();
View Full Code Here

TOP

Related Classes of org.nutz.dao.ConnCallback

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.