SQLExecutor 是一个简单的 JDBC 框架,只需要一个jar包足以。支持 Oracle, Mysql, HSQL, 和 PostgreSQL 等数据库,可轻易扩展支持新的数据库。

示例代码:

public static void testSimpleSelectWithParams()
{
    String sql = "SELECT * FROM JDBC_TEST
                           WHERE TEST_ID < ? AND TEST_DT < ?";
    ConNECtionPool conPool = new ConnectionPool(1, driverName,
                                 conURL, username, password);
    SQLExecutor sqlExec = new SQLExecutor(conPool);
    sqlExec.addParam(new Integer(8));
               //add int param with value = 8
    sqlExec.addParam(Date.valueOf("2003-05-10"));
               //add date param with value 5/10/03
    SQLResults res = sqlExec.runQueryCloseCon(sql);
               //runs the query, closes connection
    System.out.println(res.toString());
               //display entire result set in tabular form
}

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务