Advertisement
Guest User

Untitled

a guest
Jan 15th, 2016
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1.  
  2. public String printall() {
  3. String numusers = "";
  4. String dbUrl = "jdbc:derby://localhost:1527/autoviacao";
  5. String dbClass = "com.mysql.jdbc.Driver";
  6. String query = "select * from percursos";
  7. String userName = "root", password = "root";
  8. try {
  9.  
  10. Class.forName("org.apache.derby.jdbc.ClientDriver");
  11. Connection con = DriverManager.getConnection (dbUrl, userName, password);
  12. Statement stmt = con.createStatement();
  13. ResultSet rs = stmt.executeQuery(query);
  14. while (rs.next()) {
  15. numusers += rs.getString("id")+","+
  16. rs.getString("origem")+","+
  17. rs.getString("destino")+","+
  18. rs.getString("partida")+","+
  19. rs.getString("tempo")+";";
  20.  
  21.  
  22. } //end while
  23. con.close();
  24. } //end try
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement