Package org.nutz.dao

Examples of org.nutz.dao.ConnCallback


    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());
      }
View Full Code Here


    runner.run(dataSource, callback);
  }

  protected int _exec(final DaoStatement... sts) {
    final int[] re = new int[1];
    runner.run(dataSource, new ConnCallback() {
      public void invoke(Connection conn) throws Exception {
        for (DaoStatement st : sts) {
          executor.exec(conn, st);
          re[0] += st.getUpdateCount();
        }
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

      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

        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

        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

        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());
            }
View Full Code Here

    }

    @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

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.