Guest User

Untitled

a guest
Jun 23rd, 2016
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. package poe.indexer;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. public class MySQLThread extends Thread{
  8.     private Connection con;
  9.     private String MySQLHost;
  10.     private String MySQLUser;
  11.     private String MySQLPassword;
  12.    
  13.     public MySQLThread(Runnable r, String host, String user, String password ){
  14.         super(r);
  15.         MySQLHost = host;
  16.         MySQLUser = user;
  17.         MySQLPassword = password;
  18.     }
  19.    
  20.     public MySQLThread(String host, String user, String password ){
  21.         MySQLHost = host;
  22.         MySQLUser = user;
  23.         MySQLPassword = password;
  24.     }
  25.    
  26.     public void closeConnection() {
  27.         try { con.close(); } catch (SQLException e) { }
  28.     }
  29.    
  30.     public Connection getConnection(){
  31.         return con;
  32.     }
  33.    
  34.     public void run() {
  35.         try{
  36.             con = DriverManager.getConnection(MySQLHost, MySQLUser, MySQLPassword);        
  37.         }catch(Exception e) {}
  38.     }
  39. }
Add Comment
Please, Sign In to add comment