List of usage examples for org.jfree.data.jdbc JDBCPieDataset executeQuery
public void executeQuery(String query) throws SQLException
From source file:org.jw.service.factory.StatisticsChartFactory.java
public static PieDataset createPieDataset(Connection conn, String query) throws SQLException { JDBCPieDataset dataset = new JDBCPieDataset(conn); dataset.executeQuery(query); return dataset; }
From source file:com.sun.portal.os.portlets.PortletChartUtilities.java
protected static Dataset generatePieDataSet(Connection con, String sql) { JDBCPieDataset data = null; try {/*from ww w . j a va 2 s. co m*/ data = new JDBCPieDataset(con); data.executeQuery(sql); con.close(); } catch (SQLException e) { System.err.print("SQLException: "); System.err.println(e.getMessage()); } catch (Exception e) { System.err.print("Exception: "); System.err.println(e.getMessage()); } return data; }
From source file:org.posterita.core.PieChart.java
public void getDataSetFromSQL(String sql) throws OperationException { JDBCPieDataset jdbcDataset = new JDBCPieDataset(DB.getConnectionRO()); try {/*ww w. ja va 2 s . com*/ jdbcDataset.executeQuery(sql); this.dataset = jdbcDataset; } catch (SQLException e) { throw new OperationException(e); } }
From source file:com.sun.portal.os.portlets.ChartServlet.java
protected Dataset generatePieDataSet(Connection con, String sql) { JDBCPieDataset data = null; try {//from w w w.ja v a 2s . co m data = new JDBCPieDataset(con); data.executeQuery(sql); con.close(); } catch (SQLException e) { System.err.print("SQLException: "); System.err.println(e.getMessage()); } catch (Exception e) { System.err.print("Exception: "); System.err.println(e.getMessage()); } return data; }
From source file:fr.crnan.videso3d.ihm.PLNSPanel.java
private JToolBar createToolbar() { JToolBar toolbar = new JToolBar(); JButton newGraph = new JButton("Nouveau"); newGraph.addActionListener(new ActionListener() { @Override/* www.ja v a 2 s.c om*/ public void actionPerformed(ActionEvent e) { PLNSChartCreateUI chartCreator = new PLNSChartCreateUI(PLNSPanel.this); JFreeChart chart = null; try { if (chartCreator.showDialog(PLNSPanel.this)) { switch (chartCreator.getChartType()) { case 0://XY JDBCXYDataset dataset = new JDBCXYDataset(plnsAnalyzer.getConnection()); dataset.executeQuery(chartCreator.getRequest()); chart = ChartFactory.createXYAreaChart(chartCreator.getChartTitle(), chartCreator.getAbscissesTitle(), chartCreator.getOrdonneesTitle(), dataset, PlotOrientation.VERTICAL, false, true, false); break; case 1://Pie JDBCPieDataset dataset1 = new JDBCPieDataset(plnsAnalyzer.getConnection()); dataset1.executeQuery(chartCreator.getRequest()); chart = ChartFactory.createPieChart3D(chartCreator.getChartTitle(), dataset1, false, true, false); break; case 2://Category JDBCCategoryDataset dataset2 = new JDBCCategoryDataset(plnsAnalyzer.getConnection()); dataset2.executeQuery(chartCreator.getRequest()); chart = ChartFactory.createBarChart(chartCreator.getChartTitle(), chartCreator.getAbscissesTitle(), chartCreator.getOrdonneesTitle(), dataset2, PlotOrientation.VERTICAL, false, true, false); break; default: break; } } } catch (SQLException e1) { e1.printStackTrace(); JOptionPane.showMessageDialog(PLNSPanel.this, "<html>L'excution de la requte a chou :<br />" + e1 + "</html>", "Impossible de crer le graphique", JOptionPane.ERROR_MESSAGE); } if (chart != null) addChart(chart); } }); toolbar.add(newGraph); JButton retile = new JButton("Rarranger"); retile.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { desktop.tile(true); } }); toolbar.add(retile); return toolbar; }
From source file:org.jfree.chart.demo.JDBCPieChartDemo.java
private PieDataset readData() { JDBCPieDataset jdbcpiedataset = null; String s = "jdbc:postgresql://nomad/jfreechartdb"; try {//from www .j a v a 2s.co m 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"); jdbcpiedataset = new JDBCPieDataset(connection); String s1 = "SELECT * FROM PIEDATA1;"; jdbcpiedataset.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 jdbcpiedataset; }