V0rT3X_

Untitled

Nov 24th, 2020
635
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.sql.*;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         String dbURL = "jdbc:mariadb://127.0.0.1:3306/test?user=root&password=";
  6.         String driver = "org.mariadb.jdbc.Driver";
  7.  
  8.         Connection c = null;
  9.  
  10.         // load driver
  11.         try { Class.forName(driver); } catch(ClassNotFoundException ex) { ex.printStackTrace(); }
  12.  
  13.         try {
  14.             c = DriverManager.getConnection(dbURL);
  15.             Statement s = c.createStatement();
  16.             ResultSet rs = s.executeQuery("SELECT * FROM login_data");
  17.  
  18.             while(rs.next()) {
  19.                 System.out.println(rs.getInt(1) + ";" + rs.getString(2) + ";" + rs.getString(3));
  20.             }
  21.         } catch(SQLException ex) {
  22.             ex.printStackTrace();
  23.         }
  24.     }
  25. }
  26.  
RAW Paste Data