Advertisement
Guest User

Untitled

a guest
Jan 27th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. public static void main(String[] args){
  2.  
  3. try{
  4. String driverName = "com.mysql.jdbc.Driver";
  5. Class.forName(driverName);
  6.  
  7. Connection myConn = DriverManager.getConnection("jdbc:mysql://localhost/test", "test", "12345");
  8.  
  9. Statement mySmt = myConn.createStatement();
  10.  
  11. ResultSet myRs = mySmt.executeQuery("select * from usuario");
  12.  
  13. while (myRs.next()){
  14.  
  15. System.out.println(myRs.getString("id")+" - " + myRs.getString("nome")+ ","+ myRs.getString("email"));
  16. }
  17.  
  18. }catch (Exception exc){
  19. exc.printStackTrace();
  20. }
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement