Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. public class OptionList {
  2.  
  3. private Connection conn;
  4. private List<String> type_list = new ArrayList<>();
  5. private List<String> partid_list = new ArrayList<>();
  6.  
  7. public OptionList() {
  8. //conn = null;
  9. //type_list = null;
  10. //partid_list = null;
  11. }
  12.  
  13. public void listin_db() throws Exception, SQLException {
  14. JDBC ora = new JDBC();
  15.  
  16. //1. open/get connection
  17. ora.openConnection();
  18.  
  19. conn = ora.getConn();
  20.  
  21. //2. Execute query
  22. String stmnt = " select distinct PARTID, NAME "
  23. + " from INVENTORY tblA "
  24. + " inner join( "
  25. + " select distinct part_no "
  26. + " from Status )tblB on tblA.Partid = tblB.part_no ";
  27. Statement statement = conn.createStatement();
  28. ResultSet rs = statement.executeQuery(stmnt);
  29.  
  30. while (rs.next()) {
  31. type_list.add((String) rs.getString("NAME"));
  32. partid_list.add((String) rs.getString("PARTID"));
  33. }
  34.  
  35. conn.close();
  36. statement.close();
  37. ora.closeConnection();
  38.  
  39. }
  40.  
  41. public List<String> getpartid_List() {
  42. return partid_list;
  43. }
  44.  
  45. public List<String> getType_List() {
  46. return type_list;
  47. }
  48.  
  49. public String test() {
  50. return "HelooWourldd!";
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement