SQLExecutor是一个简单的JDBC框架,只需要一个jar包足以。支持Oracle,mySQL,HSQL,和PostgreSQL等数据库,可轻易扩展支持新的数据库。
示例代码:
publicstaticvoidtestSimpleSelectWithParams(){Stringsql="SELECT*FROMJDBC_TESTWHERETEST_ID<?ANDTEST_DT<?";ConnectionPoolconPool=newConnectionPool(1,driverName,conURL,username,password);SQLExecutorsqlExec=newSQLExecutor(conPool);sqlExec.addParam(newInteger(8));//addintparamwithvalue=8sqlExec.addParam(Date.valueOf("2003-05-10"));//adddateparamwithvalue5/10/03SQLResultsres=sqlExec.runQueryCloseCon(sql);//runsthequery,closesconnectionSystem.out.println(res.toString());//displayentireresultsetintabularform}
评论