亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? jdbccategorydataset.java

?? Web圖形化的Java庫
?? JAVA
字號(hào):
/* ======================================
 * JFreeChart : a free Java chart library
 * ======================================
 *
 * Project Info:  http://www.jfree.org/jfreechart/index.html
 * Project Lead:  David Gilbert (david.gilbert@object-refinery.com);
 *
 * (C) Copyright 2000-2003, by Object Refinery Limited and Contributors.
 *
 * This library is free software; you can redistribute it and/or modify it under the terms
 * of the GNU Lesser General Public License as published by the Free Software Foundation;
 * either version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License along with this
 * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
 * Boston, MA 02111-1307, USA.
 *
 * ------------------------
 * JDBCCategoryDataset.java
 * ------------------------
 * (C) Copyright 2002, 2003, by Bryan Scott and Contributors.
 *
 * Original Author:  Bryan Scott; Andy;
 * Contributor(s):   David Gilbert (for Object Refinery Limited);
 *
 * Changes
 * -------
 * 26-Apr-2002 : Creation based on JdbcXYDataSet, using code contributed from Andy;
 * 13-Aug-2002 : Updated Javadocs, import statements and formatting (DG);
 * 03-Sep-2002 : Added fix for bug 591385 (DG);
 * 18-Sep-2002 : Updated to support BIGINT (BS);
 * 16-Oct-2002 : Added fix for bug 586667 (DG);
 * 03-Feb-2003 : Added Types.DECIMAL (see bug report 677814) (DG);
 * 13-Jun-2003 : Added Types.TIME as suggest by Bryan Scott in the forum (DG);
 * 30-Jun-2003 : CVS Write test (BS);
 * 30-Jul-2003 : Added empty contructor and executeQuery(connection,string) method (BS);
 * 29-Aug-2003 : Added a 'transpose' flag, so that data can be easily transposed if required (DG);
 * 10-Sep-2003 : Added support for additional JDBC types (DG);
 * 
 */

package org.jfree.data;

import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Types;

/**
 * A {@link CategoryDataset} implementation over a database JDBC result set.
 * The dataset is populated via a call to executeQuery with the string sql
 * query.
 * The sql query must return at least two columns.  The first column will be
 * the category name and remaining columns values.
 * executeQuery can be called a number of times.
 *
 * The database connection is read-only and no write back facility exists.
 *
 * @author Bryan Scott
 */
public class JDBCCategoryDataset extends DefaultCategoryDataset {

    /** The database connection. */
    private Connection connection;

    /** The statement. */
    private Statement statement;

    /** The result set. */
    private ResultSet resultSet;

    /** The result set meta data. */
    private ResultSetMetaData metaData;
    
    /** 
     * A flag the controls whether or not the table is transposed.  The default is 'true' 
     * because this provides the behaviour described in the documentation. 
     */
    private boolean transpose = true;

    /**
     * Creates a new dataset with no database connection.
     *
     */
    public JDBCCategoryDataset() {
      super();
    }

    /**
     * Creates a new dataset with a database connection.
     *
     * @param  url  the URL of the database connection.
     * @param  driverName  the database driver class name.
     * @param  user  the database user.
     * @param  passwd  the database user's password.
     */
    public JDBCCategoryDataset(String url,
                               String driverName,
                               String user,
                               String passwd) {

        super();
        try {
            Class.forName(driverName);
            connection = DriverManager.getConnection(url, user, passwd);
            this.statement = connection.createStatement();
        }
        catch (ClassNotFoundException ex) {
            System.err.println("JDBCCategoryDataset: cannot find the database driver classes.");
            System.err.println(ex);
        }
        catch (SQLException ex) {
            System.err.println("JDBCCategoryDataset: cannot connect to the database.");
            System.err.println(ex);
        }
    }

    /**
     * Create a new dataset with the given database connection.
     *
     * @param connection  the database connection.
     */
    public JDBCCategoryDataset(Connection connection) {
        super();
        this.connection = connection;
    }

    /**
     * Creates a new dataset with the given database connection, and executes the supplied
     * query to populate the dataset.
     *
     * @param connection  the connection.
     * @param query  the query.
     */
    public JDBCCategoryDataset(Connection connection, String query) {
        this(connection);
        executeQuery(query);
    }
    
    /**
     * Returns a flag that controls whether or not the table values are transposed when added
     * to the dataset.
     * 
     * @return A boolean.
     */
    public boolean getTranspose() {
        return this.transpose;
    }
    
    /**
     * Sets a flag that controls whether or not the table values are transposed when added to
     * the dataset.
     * 
     * @param transpose  the flag.
     */
    public void setTranspose(boolean transpose) {
        this.transpose = transpose;
    }

    /**
     * Populates the dataset by executing the supplied query against the existing database
     * connection.  If no connection exists then no action is taken.
     * <p>
     * The results from the query are extracted and cached locally, thus applying an upper
     * limit on how many rows can be retrieved successfully.
     *
     * @param query  the query.
     */
    public void executeQuery(String query) {
      executeQuery(connection, query);
    }

    /**
     * Populates the dataset by executing the supplied query against the existing database
     * connection.  If no connection exists then no action is taken.
     * <p>
     * The results from the query are extracted and cached locally, thus applying an upper
     * limit on how many rows can be retrieved successfully.
     *
     * @param con  the connection.
     * @param query  the query.
     */
    public void executeQuery(Connection con, String query) {

        // if there is no connection, just return
        if (con == null) {
            System.err.println("JDBCCategoryDataset.executeQuery(...) : there is no connection.");
            return;
        }

        try {
            statement = con.createStatement();
            resultSet = statement.executeQuery(query);
            metaData = resultSet.getMetaData();

            int columnCount = metaData.getColumnCount();

            if (columnCount < 2) {
                System.err.println("JDBCCategoryDataset.executeQuery(...) : insufficient columns "
                                   + "returned from the database.");
                return;
            }

            while (resultSet.next()) {
                // first column contains the row key...
                Comparable rowKey = resultSet.getString(1);
                for (int column = 2; column <= columnCount; column++) {

                    Comparable columnKey = metaData.getColumnName(column);
                    Number value = null;
                    int columnType = metaData.getColumnType(column);

                    switch (columnType) {
                        case Types.TINYINT:
                        case Types.SMALLINT:
                        case Types.INTEGER:
                        case Types.BIGINT:
                        case Types.FLOAT:
                        case Types.DOUBLE:
                        case Types.DECIMAL:
                        case Types.NUMERIC:
                        case Types.REAL:
                            value = (Number) resultSet.getObject(column);
                            if (transpose) {
                                setValue(value, columnKey, rowKey);                                
                            }
                            else {
                                setValue(value, rowKey, columnKey);
                            }
                            break;

                        case Types.DATE:
                        case Types.TIME:
                        case Types.TIMESTAMP:
                            Date date = (Date) resultSet.getObject(column);
                            value = new Long(date.getTime());
                            if (transpose) {
                                setValue(value, columnKey, rowKey);                                
                            }
                            else {
                                setValue(value, rowKey, columnKey);
                            }
                            break;
                         
                        case Types.CHAR:
                        case Types.VARCHAR:
                        case Types.LONGVARCHAR:
                            String string = (String) resultSet.getObject(column);
                            try {
                                value = Double.valueOf(string);
                                if (transpose) {
                                    setValue(value, columnKey, rowKey);                                
                                }
                                else {
                                    setValue(value, rowKey, columnKey);
                                }
                            }
                            catch (NumberFormatException e) {
                                // suppress (value defaults to null)
                            }
                            break;

                        default:
                            // not a value, can't use it (defaults to null)
                            break;
                    }
                }
            }

            fireDatasetChanged();
        }
        catch (SQLException ex) {
            System.err.println(ex);
        }
        finally {
            if (resultSet != null) {
                try {
                    resultSet.close();
                }
                catch (Exception e) {
                    // report this?
                }
            }
            if (statement != null) {
                try {
                    statement.close();
                }
                catch (Exception e) {
                    // report this?
                }
            }
        }
    }

}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
中文文精品字幕一区二区| 欧美一区二区网站| 国产精品小仙女| 精品中文字幕一区二区小辣椒| 亚洲综合成人在线| 午夜久久久久久久久久一区二区| 亚洲欧美日韩中文字幕一区二区三区 | 精品国内片67194| 日韩午夜在线观看| xfplay精品久久| 国产精品理论片在线观看| 国产精品视频免费| 一区二区三区免费观看| 亚洲国产aⅴ成人精品无吗| 亚洲国产一区视频| 美女mm1313爽爽久久久蜜臀| 国产综合久久久久影院| 成人黄色在线视频| 欧美日韩国产综合草草| 日韩一区二区免费在线观看| 精品国产精品一区二区夜夜嗨| 国产欧美日韩在线视频| 成人欧美一区二区三区视频网页| 亚洲伦理在线免费看| 视频在线观看一区| 国产成人一区在线| 在线精品视频小说1| 欧美成人女星排名| 亚洲日本乱码在线观看| 日韩av二区在线播放| 国产麻豆成人传媒免费观看| 91麻豆国产福利在线观看| 久久免费精品国产久精品久久久久| 欧美www视频| 亚洲三级在线免费| 激情欧美一区二区| 在线观看区一区二| 国产性天天综合网| 日韩高清不卡一区| 色综合咪咪久久| 久久人人97超碰com| 樱花影视一区二区| 国产成人av一区二区三区在线| 91电影在线观看| 久久精品欧美一区二区三区麻豆| 亚洲一区二区三区精品在线| 国产精品一二三区| 91麻豆精品国产| 亚洲综合无码一区二区| 国产一区二区不卡| 日韩午夜av电影| 午夜欧美在线一二页| av中文一区二区三区| 精品卡一卡二卡三卡四在线| 亚洲一区二区视频| 91在线国内视频| 欧美国产精品专区| 国产美女主播视频一区| 91精品在线麻豆| 午夜精品久久久久久久久| 99国内精品久久| 国产精品久久久久久久久图文区| 国内精品写真在线观看| 日韩区在线观看| 免费久久99精品国产| 欧美伦理影视网| 午夜精品免费在线| 欧美色大人视频| 午夜欧美一区二区三区在线播放| 日本电影欧美片| 亚洲精品福利视频网站| 91在线观看美女| 亚洲精品中文在线影院| 91麻豆精东视频| 亚洲大片精品永久免费| 欧美日韩一级片网站| 天天综合天天做天天综合| 欧美美女直播网站| 麻豆成人久久精品二区三区小说| 欧美福利视频一区| 麻豆国产欧美一区二区三区| 欧美不卡在线视频| 国产精品一区二区三区乱码 | av在线不卡免费看| 国产精品久久久久久妇女6080| 国产精品1024| 国产精品国产三级国产专播品爱网 | 欧美日韩mp4| 日韩二区在线观看| 精品国产乱码久久久久久免费| 国产一区不卡在线| 欧美激情自拍偷拍| 一本到一区二区三区| 午夜久久久久久久久| 欧美电视剧在线观看完整版| 国产在线播放一区二区三区| 欧美国产激情二区三区| 91理论电影在线观看| 婷婷成人激情在线网| 久久人人爽人人爽| 欧美视频精品在线观看| 天堂久久一区二区三区| 久久久久国色av免费看影院| 91麻豆国产自产在线观看| 天天操天天色综合| 国产日韩欧美综合在线| 欧美在线啊v一区| 黑人精品欧美一区二区蜜桃 | 91麻豆精品国产自产在线观看一区 | 亚洲午夜一区二区| 久久婷婷国产综合精品青草| 色综合久久天天| 久久99热狠狠色一区二区| 国产精品麻豆一区二区| 欧美一区二区在线视频| 成人开心网精品视频| 蜜桃视频在线观看一区| 亚洲男同1069视频| 久久久高清一区二区三区| 欧美日韩视频在线观看一区二区三区| 国产在线精品免费| 亚洲成人一区二区| 亚洲另类中文字| 久久嫩草精品久久久精品| 91精品国产全国免费观看| 91尤物视频在线观看| 国产成人亚洲精品青草天美| 日韩精品欧美精品| 亚洲激情一二三区| 中文在线资源观看网站视频免费不卡 | 日本道色综合久久| 成人激情小说乱人伦| 国产一区二区三区在线观看精品 | 日韩女优视频免费观看| 色屁屁一区二区| 91污在线观看| 大胆亚洲人体视频| 国产精品亚洲成人| 九九视频精品免费| 麻豆成人91精品二区三区| 亚洲国产成人精品视频| 亚洲男同1069视频| 亚洲婷婷在线视频| 亚洲日本乱码在线观看| 国产精品久久久久久亚洲毛片 | 日韩视频免费观看高清完整版 | 亚洲成人av一区| 亚洲色图欧美在线| 亚洲美女视频一区| 一区二区三区四区激情 | 日韩欧美中文字幕精品| 欧美日韩国产一级二级| 欧美美女直播网站| 欧美性一区二区| 精品污污网站免费看| 欧美日精品一区视频| 欧美丝袜自拍制服另类| 欧美一区二区观看视频| 欧美夫妻性生活| 91精品久久久久久久99蜜桃 | 欧美日韩国产影片| 欧美日韩免费在线视频| 欧美剧情片在线观看| 9191国产精品| 欧美精品一区男女天堂| 国产亚洲欧洲一区高清在线观看| 日本一区二区三级电影在线观看| 国产农村妇女毛片精品久久麻豆 | jlzzjlzz国产精品久久| 91亚洲资源网| 欧美电影一区二区| 精品国产伦理网| 亚洲人成在线观看一区二区| 性做久久久久久| 狠狠久久亚洲欧美| 99re66热这里只有精品3直播 | 日韩色视频在线观看| 精品国产乱码久久久久久久久| 国产偷国产偷精品高清尤物 | 国产99久久久国产精品免费看| 成人精品视频一区| 欧美体内she精视频| 精品欧美乱码久久久久久| 国产日韩欧美一区二区三区综合| 亚洲激情图片小说视频| 日产欧产美韩系列久久99| 国产精品性做久久久久久| 在线看国产一区| 国产视频视频一区| 日韩激情一二三区| 成人一级片在线观看| 666欧美在线视频| 亚洲欧洲精品一区二区三区| 婷婷丁香激情综合| 99久久综合狠狠综合久久| 日韩欧美综合一区| 一区二区高清免费观看影视大全 | 国产三区在线成人av| 亚洲国产欧美另类丝袜| 成年人网站91|