Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- class MysqlCon {
- public static void main(String args[]) {
- try {
- Class.forName("com.mysql.jdbc.Driver");
- Connection con = DriverManager.getConnection(
- "jdbc:mysql://localhost:3306/banco", "matheus", "123456");
- Statement stmt = con.createStatement();
- ResultSet rs = stmt.executeQuery("select * from usuario");
- while (rs.next()) {
- System.out.println(rs.getInt(1) + " " + rs.getString(2) + " " + rs.getString(3));
- }
- con.close();
- } catch (ClassNotFoundException | SQLException e) {
- System.out.println(e);
- }
- }
- }
Add Comment
Please, Sign In to add comment