-1

I used a code that allows me to see the result of my treatment graphically. I want to store the graph in my MySql database (in WampServer). How can I do this?

Here is what I have tried:

if (jCheckBox1.isSelected()) {
    try {
        con = getConnection("jdbc:mysql://localhost:3306/base_rapport_tt", "root", "");
        Statement statement = con.createStatement(rs.TYPE_FORWARD_ONLY, rs.CONCUR_READ_ONLY);
        String sql1 = "Select last_updated_by,(count(id_incident) )*100/(Select count(id_incident) from incident where Status like 'Closed' and open_time between '" + jTextField1.getText() + "' and '" + jTextField2.getText() + "')from incident  where  Status like 'Closed'and open_time between '" + jTextField1.getText() + "' and '" + jTextField2.getText() + "' group by last_updated_by";
        rs1 = statement.executeQuery(sql1);
        DefaultPieDataset pieDataset = new DefaultPieDataset();
        while (rs1.next()) {
            pieDataset.setValue(rs1.getString("last_updated_by"), rs1.getDouble(2));
        }
        JFreeChart chart = ChartFactory.createPieChart3D("Taux résolution par personne", pieDataset, true, true, false);
        PiePlot3D piePlot3d = (PiePlot3D) chart.getPlot();
        piePlot3d.setLabelGenerator(new StandardPieSectionLabelGenerator("{0}={1}"));
        fenetre fen1 = new fenetre();
        pnl = new JPanel(new BorderLayout());
        fen1.setContentPane(pnl);
        fen1.setVisible(true);
        setSize(700, 700);
        ChartPanel cPanel1 = new ChartPanel(chart);
        pnl.add(cPanel1);
    } catch (Exception e) {
        JOptionPane.showMessageDialog(this, e);
    }
}
Tim Lewis
  • 27,813
  • 13
  • 73
  • 102

1 Answers1

2

Generally, yes, you can store arbitrary binary data in MySQL using BLOB type. An example schema:

CREATE TABLE images (
    id INT PRIMARY KEY AUTO_INCREMENT,
    description VARCHAR(40),
    data BLOB
);

It appears you're using Java on the backend, if so you should check out the Using Large Objects tutorial.

However, there are reasons you may not want to do this; see Should I use MySQL blob field type? for some discussion on that.

Community
  • 1
  • 1
pioto
  • 2,472
  • 23
  • 37