Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. try {
  2. Class.forName("com.mysql.jdbc.Driver");
  3. System.out.println("Caricamento Diver");
  4. }catch(ClassNotFoundException e) {
  5.  
  6. }
  7.  
  8. String url = "jdbc:mysql://localhost:3306/scrum?user=root&password=";
  9.  
  10. System.out.println("Connessione al database in corso...");
  11. try (Connection connection = DriverManager.getConnection(url)) {
  12. System.out.println("Database connesso!");
  13. Statement stm = connection.createStatement();
  14. Statement stm1 = connection.createStatement();
  15. //controllo credenziali
  16.  
  17. ResultSet rs = stm.executeQuery("SELECT idAttività FROM soggetto");
  18. ResultSet rs1 = stm1.executeQuery("SELECT Nominativo FROM soggetto");
  19. while (rs.next() && rs1.next()) {
  20. cB.getItems().add(rs.getString("idAttività")+ " " + rs1.getString("Nominativo"));
  21.  
  22. //combo = rs.getString("idAttività") + rs.getString("Nominativo");
  23.  
  24. }
  25. }catch(SQLException e) {
  26. throw new IllegalStateException("Impossibile connettersi al database!", e);
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement