⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jdbcxychartdemo.java

📁 很好的制作统计图表的代码
💻 JAVA
字号:
// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov  Date: 7/18/2005 5:13:48 PM
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 

package org.jfree.chart.demo;

import java.awt.Color;
import java.io.PrintStream;
import java.sql.*;
import org.jfree.chart.*;
import org.jfree.data.jdbc.JDBCXYDataset;
import org.jfree.data.xy.XYDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;

public class JDBCXYChartDemo extends ApplicationFrame
{

    public JDBCXYChartDemo(String s)
    {
        super(s);
        XYDataset xydataset = readData();
        JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("JDBC XY Chart Demo", "Date", "Value", xydataset, true, true, false);
        jfreechart.setBackgroundPaint(Color.yellow);
        ChartPanel chartpanel = new ChartPanel(jfreechart);
        setContentPane(chartpanel);
    }

    private XYDataset readData()
    {
        JDBCXYDataset jdbcxydataset = null;
        String s = "jdbc:postgresql://nomad/jfreechartdb";
        try
        {
            Class.forName("org.postgresql.Driver");
        }
        catch(ClassNotFoundException classnotfoundexception)
        {
            System.err.print("ClassNotFoundException: ");
            System.err.println(classnotfoundexception.getMessage());
        }
        try
        {
            Connection connection = DriverManager.getConnection(s, "jfreechart", "password");
            jdbcxydataset = new JDBCXYDataset(connection);
            String s1 = "SELECT * FROM XYDATA1;";
            jdbcxydataset.executeQuery(s1);
            connection.close();
        }
        catch(SQLException sqlexception)
        {
            System.err.print("SQLException: ");
            System.err.println(sqlexception.getMessage());
        }
        catch(Exception exception)
        {
            System.err.print("Exception: ");
            System.err.println(exception.getMessage());
        }
        return jdbcxydataset;
    }

    public static void main(String args[])
    {
        JDBCXYChartDemo jdbcxychartdemo = new JDBCXYChartDemo("JDBC XY Chart Demo");
        jdbcxychartdemo.pack();
        RefineryUtilities.centerFrameOnScreen(jdbcxychartdemo);
        jdbcxychartdemo.setVisible(true);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -