List of usage examples for org.jfree.data.jdbc JDBCXYDataset JDBCXYDataset
public JDBCXYDataset(Connection con) throws SQLException
From source file:org.jfree.chart.demo.JDBCXYChartDemo.java
private XYDataset readData() { JDBCXYDataset jdbcxydataset = null;//from w w w.ja v a 2 s.co m 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; }
From source file:com.sun.portal.os.portlets.PortletChartUtilities.java
private static JDBCXYDataset generateXYDataSet(Connection con, String sql) { JDBCXYDataset data = null;/* w w w. j ava 2 s .com*/ try { data = new JDBCXYDataset(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/*ww w . j a 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:com.sun.portal.os.portlets.ChartServlet.java
private JDBCXYDataset generateXYDataSet(Connection con, String sql) { JDBCXYDataset data = null;//w w w . ja v a 2 s. com try { data = new JDBCXYDataset(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; }