public JSONArray queryReturnBrandItemNumber(String brand, int item_number) throws Exception {
PreparedStatement query = null;
Connection conn = null;
ToJSON converter = new ToJSON();
JSONArray json = new JSONArray();
try {
conn = oraclePcPartsConnection();
query = conn.prepareStatement("select PC_PARTS_PK, PC_PARTS_TITLE, PC_PARTS_CODE, PC_PARTS_MAKER, PC_PARTS_AVAIL, PC_PARTS_DESC " +
"from PC_PARTS " +
"where UPPER(PC_PARTS_MAKER) = ? " +
"and PC_PARTS_CODE = ?");
/*
* protect against sql injection
* when you have more than one ?, it will go in chronological
* order.
*/
query.setString(1, brand.toUpperCase()); //first ?
query.setInt(2, item_number); //second ?
ResultSet rs = query.executeQuery();
json = converter.toJSONArray(rs);
query.close(); //close connection
}
catch(SQLException sqlError) {
sqlError.printStackTrace();
return json;