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; //初始化C3P0数据源 static { ComboPooledDataSource cpds = new ComboPooledDataSource(); ds = cpds; } public static void testKeyedHandler() throws SQLException { String sql = "select id,name,password from user"; QueryRunner qr = new QueryRunner(ds); Map<Object, Map<String, Object>> map = qr.query(sql, new KeyedHandler<Object>("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(); }}
//我的添加的一些jar包
**
//我的XML文件**
// 运行有错误啊 。。。。我打完代码 又跟着书上的代码对照了好久,是一样的 但是运行不出来结果 烦。。。我的书是传智播客的书
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号