I need to create a XYLineChart with values from database (Java(Mysql)

空扰寡人 提交于 2019-12-02 11:21:30
dic19

You might want to take a look to this topic: Multiple graphs in multiple figures using jFreeChart. In the answer is described how to work with JFreeChart and SwingWorker to make time consuming tasks (like database calls) in a background thread and update Swing components (in this case the chart) in the Event Dispatch Thread where Swing components creation and update should take place.

Having said this you should do database calls within doInBackground() method publishing interim results through publish() method and adding those to the chart within process() method.

About database call you should have a look to JDBC technology. There are official trails here:

Depending on what database engine are you using there are some good tutorials too, just google for "jdbc + used DBMS" (e.g.: jdbc + mysql, jdbc + postgresql, jdbc + sqlite, etc.). Here is a really good one:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!