Home > Database > Mysql Tutorial > body text

mysql-求求大神帮个忙。。。。。非常感谢!!!!!!

WBOY
Release: 2016-06-06 09:36:29
Original
995 people have browsed it

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>
Copy after login

//我的添加的一些JAR包

图片说明

**
//我的XML文件**

图片说明

// 运行有错误啊 。。。。我打完代码 又跟着书上的代码对照了好久,是一样的 但是运行不出来结果 烦。。。我的书是传智播客的书

图片说明

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template