daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest Jan 20th, 2017 420 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package pack;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.ResultSet;
  6. import java.sql.SQLException;
  7. import java.sql.Statement;
  8.  
  9. public class Main {
  10.     Connection con = null;
  11.     public Main()
  12.     {
  13.         try{
  14.             Class.forName("com.mysql.jdbc.Driver");
  15.         }
  16.         catch(ClassNotFoundException e)
  17.         {
  18.             return;
  19.         }
  20.        
  21.         con = null;
  22.        
  23.         try {
  24.             con = DriverManager.getConnection("jdbc:mysql://84.200.222.219/insta?" +
  25.                                               "user=insta&password=yxcvbnm");
  26.         } catch (SQLException e) {
  27.            
  28.             e.printStackTrace();
  29.         }
  30.     }
  31.     public static void main(String[] args) {
  32.        
  33.         Main m = new Main();
  34.         m.selectAll();
  35.     }
  36.    
  37.     public void selectAll()
  38.     {
  39.         Statement stat = null;
  40.         try {
  41.             stat = con.createStatement();
  42.         } catch (SQLException e1) {
  43.             // TODO Auto-generated catch block
  44.             e1.printStackTrace();
  45.         }
  46.         String sql = "SELECT * From accounts";
  47.        
  48.         try {
  49.             ResultSet res = stat.executeQuery(sql);
  50.             while(res.next())
  51.             {
  52.                 String id = res.getString(1);
  53.                 String User = res.getString(2);
  54.                 String Password = res.getString(3);
  55.                 String ip = res.getString(4);
  56.                 System.out.println("ID = " + id + " ," +"User = " + User + " ," + "Password = " + Password + " ," + "IP-Adresse = " + ip);
  57.             }
  58.             res.close();
  59.             stat.close();
  60.         } catch (SQLException e) {
  61.             // TODO Auto-generated catch block
  62.             e.printStackTrace();
  63.         }
  64.        
  65.        
  66.     }
  67.  
  68. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top