我想生成一個包含兩列的圖。一個將用於報價,另一個將用於發票(兩者將進行比較)。報價單和發票分爲兩個單獨的表格,分別稱爲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