Mattie

Mattie

Jan 2nd, 2011
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1. public class Database extends PircBot implements Runnable
  2. {
  3.  
  4.     private Statement           stmt;
  5.     private Connection          con;
  6.     private String              USERNAME    = "admin_ircbot";
  7.     private String              PASSWORD    = "pazzzzzzzzzzzzzword(nee dezeis fake :p)";
  8.     private String              DBNAME      = "admin_ircbot";
  9.     private String              DBURL       = "jdbc:mysql://mattie-systems.nl:3306/" + DBNAME;
  10. //  private ResultSet           rs;
  11.     private MyBot               bot;
  12.     private java.lang.Thread    t;
  13.     private int                 errorcount  = 0;
  14.     private Debug               d           = new Debug();
  15.     private ResultSet           rs;
  16.  
  17.     public Database(MyBot bot)
  18.     {
  19.         this.bot = bot;
  20.         activateDBconnection();
  21.         t = new Thread(this);
  22.         t.start();
  23.     }
  24.  
  25.     public void activateDBconnection()
  26.     {
  27.         try
  28.         {
  29.             Class.forName("com.mysql.jdbc.Driver");
  30.  
  31.             // Define URL of database server for
  32.             // database named mysql on the localhost
  33.             // with the default port number 3306.
  34.             String url = DBURL;
  35.  
  36.             // Get a connection to the database for a
  37.             // user named root with a blank password.
  38.             // This user is the default administrator
  39.             // having full privileges to do anything.
  40.             con = DriverManager.getConnection(url, USERNAME, PASSWORD);
  41.  
  42.             // Display URL and connection information
  43.             System.out.println("URL: " + url);
  44.             System.out.println("Connection: " + con);
  45.  
  46.             // Get a Statement object
  47.             stmt = con.createStatement();
  48.  
  49.             getUsersFromDB();
  50.  
  51.         } catch (Exception e)
  52.         {
  53.  
  54.             genereerCriticalError(e);
  55.         }
  56.     }
Advertisement
Add Comment
Please, Sign In to add comment