Maison >base de données >tutoriel mysql >mysql-求求大神帮个忙。。。。。非常感谢!!!!!!
mysqljdbc
<code> 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 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(); }}</object></object></code>
//我的添加的一些JAR包
**
//我的XML文件**
// 运行有错误啊 。。。。我打完代码 又跟着书上的代码对照了好久,是一样的 但是运行不出来结果 烦。。。我的书是传智播客的书