DBUTILS example

zhaozj2021-02-16  46

// Use DBUTILS1.0 version

Import java.util. *; import java.util.logging. *; import java.sql. *; import org.apache.commons.dbutils. *; import org.apache.commons.dbutils.handlers. *;

Public class testdbunits {public static void main (String [] args) throws exception {testdbunits test = new testdbunits (); for (int i = 0; i <1; i ) {test.testquery1 (); test.testquery2 () ; test.testUpdate ();}} public void testQuery1 () {try {QueryRunner qr = new QueryRunner (); ResultSetHandler rsh = new ArrayListHandler (); String strsql = "select * from test1"; ArrayList result = (ArrayList) qr .query (getConnection (), strsql, rsh; //system.out.print ("");} catch (exception ex) {ex.printstacktrace (system.out);}}} public void testquery2 () {TRY { QueryRunner qr = new QueryRunner (); ResultSetHandler rsh = new MapListHandler (); String strsql = "select * from test1"; ArrayList result = (ArrayList) qr.query (getConnection (), strsql, rsh); for (int i = 0; i 转载请注明原文地址:https://www.9cbs.com/read-20883.html


New Post(0)