& Quot; packageedu. jju. jdbc. example. dao; importcom. mchange. v2.c3p0. comboPooledDataSource; importjava. SQL. SQLException; importjava. util. map; importjavax. SQL. dataSource; importorg. apache. commons. dbutils. queryRunner; importorg. apache. commons. dbut... mysqljdbc
Package edu. jju. jdbc. example. dao; import com. mchange. v2.c3p0. comboPooledDataSource; import java. SQL. SQLException; import java. util. map; import javax. SQL. dataSource; import org. apache. commons. dbutils. queryRunner; import org. apache. commons. dbutils. handlers. keyedHandler;/***** @ author Administrator */public class ResultSetTest09 {public static DataSource ds = null; // initialize the C3P0 data source static {ComboPooledDataSource cpds = new ComboPooledDataSource (); ds = cpd;} public static void testKeyedHandler () throws SQLException {String SQL = "select id, name, password from user"; QueryRunner qr = new QueryRunner (ds); Map
> Map = qr. query (SQL, new KeyedHandler
("Id"); Map umap = (Map) map. get (new Integer (1); String uname = (String) umap. get ("name"); String upassword = (String) umap. get ("password"); System. out. println (uname + ":" + upassword);} public static void main (String [] args) throws SQLException {testKeyedHandler ();}}// Some JAR packages I added
**
// My XML file **
// An error occurred while running .... After I finished the code, I followed the code in the book for a long time. it was the same, but the running results were annoying... My book is The Book of Chuanzhi podcast