我想生成一个包含两列的图。一个将用于报价,另一个将用于发票(两者将进行比较)。报价单和发票分为两个单独的表格,分别称为quotedb
和invoicedb
。我的问题是我只能让它产生报价。我是新来的图,所以我的问题是,我如何操作下面的编码,以便它可以显示来自两个图的数据。如何在一张图上生成来自两个不同MySQL表的结果
这里是编码调用从quotedb
数据:
//declaring the type of category in the column
String text =cboQIMonth.getSelectedItem().toString();
String empno = cboEmployee.getSelectedItem().toString();
String year = cboQIYear.getSelectedItem().toString();
//connecting the database
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost:3306/salventri","root","password");
//select statement to retrieve data for the graph
PreparedStatement stmt = con.prepareStatement("select * from quotedb where EXTRACT(MONTH from quote_date)='" + monthnum + "' and EXTRACT(YEAR from quote_date) ='" + year + "' and username=" + empno +"");
ResultSet rs = stmt.executeQuery();
DefaultCategoryDataset ddataset = new DefaultCategoryDataset();
while (rs.next())
{
//data to be displayed on the graph
ddataset.setValue(rs.getInt("quote_total"),
rs.getString("quote_number") + " by " + rs.getInt("username"),
monthnum + " " + cboQIYear.getSelectedItem().toString());
}
*”如何在Netbeans IDE中的单个图表**上生成两个不同MySQL表格的结果?“***在Eclipse中执行相同的操作(您的IDE与该问题无关)。 –
我对Eclipse的使用经验与Netbeans相同,所以我不确定如何在 – Osiris93
@AndrewThompson上做到这一点但是我怎样才能让它从两张不同的表中读取呢?我需要创建第二个'ResultSet'语句吗? – Osiris93