set serveroutput on size 1000000
CREATE OR REPLACE PROCEDURE print_table( p_query in varchar2 )
AUTHID CURRENT_USER
/* Author : Tom Kyte
Last update: yaanzy
*/
IS
l_theCursor integer default dbms_sql.open_cursor;
l_columnValue varchar2(4000);
l_status integer;
l_descTbl dbms_sql.desc_tab;
l_colCnt number;
l_rowCnt number:=1;
BEGIN
dbms_sql.parse( l_theCursor, p_query, dbms_sql.native );
dbms_sql.describe_columns( l_theCursor, l_colCnt, l_descTbl);
for i in 1 .. l_colCnt loop
dbms_sql.define_column(l_theCursor, i, l_columnValue, 4000);
end loop;
l_status := dbms_sql.execute(l_theCursor);
while ( dbms_sql.fetch_rows(l_theCursor) > 0 ) loop
for i in 1 .. l_colCnt loop
dbms_sql.column_value( l_theCursor, i, l_columnValue );
dbms_output.put_line( rpad( l_descTbl(i).col_name, 30 )
|| ': ' ||
l_columnValue );
end loop;
dbms_output.put_line( '[Row:'||l_rowCnt||']---------------------------------------------------' );
l_rowCnt := l_rowCnt + 1;
end loop;
EXCEPTION
when others then
dbms_sql.close_cursor( l_theCursor );
RAISE;
END print_table;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Graphics;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.ui.ApplicationFrame;
import org.jfree.ui.RefineryUtilities;
public class Test extends ApplicationFrame {
private static final long serialVersionUID = 1L;
public Test(String arg0) {
super(arg0);
setLayout(new BorderLayout());
DefaultPieDataset categorydataset = getDataSet();
JFreeChart jfreechart = createChart(categorydataset);
ChartPanel chartpanel = new ChartPanel(jfreechart);
chartpanel.setPreferredSize(new Dimension(500, 270));
//chartpanel.PRINT_COMMAND ;
//setContentPane(chartpanel);
add(chartpanel,BorderLayout.CENTER);
JPanel north=new JPanel();
JMenuBar jbar=new JMenuBar();
JMenu jmu=new JMenu("file");
JMenuItem jmi=new JMenuItem("print...");
//jmi.addActionListener(chartpanel.PRINT_COMMAND);
jmi.setActionCommand(ChartPanel.PRINT_COMMAND);
jmi.addActionListener(chartpanel);
jmu.add(jmi);
jbar.add(jmu);
JMenu jmu2=new JMenu("help");
jbar.add(jmu2);
//jbar.add(jmu);
north.add(jbar);
add(north,BorderLayout.NORTH);
}
private static DefaultPieDataset getDataSet() {
DefaultPieDataset dataset = new DefaultPieDataset();
dataset.setValue("苹果", 100);
dataset.setValue("梨子", 200);
dataset.setValue("葡萄", 300);
dataset.setValue("香蕉", 400);
dataset.setValue("荔枝", 500);
return dataset;
}
private static JFreeChart createChart(DefaultPieDataset data) {
// DefaultPieDataset data = getDataSet();
JFreeChart chart = ChartFactory.createPieChart3D("水果产量图", // 图表标题
data, true, false, false);
return chart;
}
public static JPanel createDemoPanel()
{
JFreeChart jfreechart = createChart(getDataSet());
ChartPanel cp=new ChartPanel(jfreechart);
//cp.PRINT_COMMAND;
//cp.addChartMouseListener(arg0);
return cp;
}
public void pain(Graphics g)
{
//Graphics2D
}
public static void main(String[] args) {
// JPanel jp=createDemoPanel();
//
// jp.setSize(500, 600);
// jp.setVisible(true);
// TODO Auto-generated method stub
//Log.getInstance().addTarget(new PrintStreamLogTarget());
Test barchart3ddemo2 = new Test("3D Bar Chart Demo 2");
barchart3ddemo2.pack();
//barchart3ddemo2.get
RefineryUtilities.centerFrameOnScreen(barchart3ddemo2);
barchart3ddemo2.setVisible(true);
// Graphics g=new DebugGraphics();
// barchart3ddemo2.print(g);
// ChartMouseListener e;
// JTable table=new JTable();
// try {
// table.print();
// } catch (PrinterException e) {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
}
}