Guest User

Untitled

a guest
Jan 22nd, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. Connection dbcon = null;
  2. try {
  3. Class.forName("oracle.jdbc.driver.OracleDriver");
  4. dbcon = DriverManager.getConnection("
  5. jdbc:oracle:thin:@localhost:1521:XE", "USERNAME", "PASSWORD");
  6. Statement st = dbcon.createStatement();
  7. String combo = "Select EMP_IDNUM from employees";
  8. ResultSet res = st.executeQuery(combo);
  9. while(res.next()){
  10. String ids = res.getString("EMP_IDNUM");
  11. String [] str = new String[]{ids};
  12. cboId = new JComboBox(str);
  13. }
  14. } catch (Exception d) {
  15. System.out.println(d);
  16. }
  17.  
  18. String [] str = new String[]{ids};
  19.  
  20. if(rs.getRow()>0){
  21. String [] str = new String[res.getRow()];
  22. int i=0;
  23. while(res.next()){
  24. str[i++] = res.getString("EMP_IDNUM");
  25. }
  26. }
  27. JComboBox jcb = new JComboBox(str);
  28.  
  29. Vector v = new Vector();
  30. while(res.next()){
  31. String ids = res.getString("EMP_IDNUM");
  32. v.add(ids)
  33. }
  34. JComboBox jcb = new JComboBox(v);
  35.  
  36. try {
  37.  
  38. } catch (Exception d) {
  39. System.out.println(d);
  40. } finally {
  41. try {
  42. st.close()
  43. res.close()
  44. dbcon.close()
  45. } catch (Exception d) {
  46. //not important
  47. }
  48. }
Add Comment
Please, Sign In to add comment