Guest User

Untitled

a guest
Jan 5th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import java.sql.*;
  2.  
  3. class MysqlCon {
  4.  
  5. public static void main(String args[]) {
  6. try {
  7. Class.forName("com.mysql.jdbc.Driver");
  8. Connection con = DriverManager.getConnection(
  9. "jdbc:mysql://localhost:3306/banco", "matheus", "123456");
  10. Statement stmt = con.createStatement();
  11. ResultSet rs = stmt.executeQuery("select * from usuario");
  12. while (rs.next()) {
  13. System.out.println(rs.getInt(1) + " " + rs.getString(2) + " " + rs.getString(3));
  14. }
  15. con.close();
  16. } catch (ClassNotFoundException | SQLException e) {
  17. System.out.println(e);
  18. }
  19. }
  20. }
Add Comment
Please, Sign In to add comment