Advertisement
Guest User

Untitled

a guest
Feb 20th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. public static void getSupplierOfCoffee(String coffeeName, String[] supplierName)
  2. throws SQLException {
  3.  
  4. Connection con = DriverManager.getConnection("jdbc:default:connection");
  5. PreparedStatement pstmt = null;
  6. ResultSet rs = null;
  7.  
  8. String query =
  9. "select SUPPLIERS.SUP_NAME " +
  10. "from SUPPLIERS, COFFEES " +
  11. "where " +
  12. "SUPPLIERS.SUP_ID = COFFEES.SUP_ID " +
  13. "and ? = COFFEES.COF_NAME";
  14.  
  15. pstmt = con.prepareStatement(query);
  16. pstmt.setString(1, coffeeName);
  17. rs = pstmt.executeQuery();
  18.  
  19. if (rs.next()) {
  20. supplierName[0] = rs.getString(1);
  21. } else {
  22. supplierName[0] = null;
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement