| arr[rs.getInt("productID")] = rs.getString("productname"); |
| //////////////////////////////////////////////////////////// //Get the sales totals from the database //////////////////////////////////////////////////////////// public float[] getSales(int products) { float[] arr = new float[products]; Connection con; Statement stmt; ResultSet rs; int count = 0; String sql = "select productID, amount from p_sales"; try { //Load Driver: Class.forName(driver); //Connect to the database with the url con = DriverManager.getConnection(dburl , dbuid , dbpwd); stmt = con.createStatement(); //Get ResultSet rs = stmt.executeQuery(sql); while(rs.next()) { int product = rs.getInt("productID"); //Check that the productID is valid if (product >= 0 && product < products) { //Add to product total arr[product] = rs.getFloat("amount"); count ; } } stmt.close(); con.close(); } catch (java.lang.Exception ex) { arr[0] = -1.0f; } return arr; } |
| int product = rs.getInt("productID"); arr[product] = rs.getFloat("amount"); |
| Color pieColorArray[] = {new Color(210,60,60), new Color(60,210,60)…} |
| curPieColor ; if(curPieColor >= pieColorArray.length) {curPieColor = 0;} |
评论加载中…
![]() |