Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package bot_versie_08;
- import java.sql.*;
- public class Database
- {
- private Statement stmt;
- private Connection con;
- private String USERNAME = "admin_ircbot";
- private String PASSWORD = "password";
- private String DBNAME = "admin_ircbot";
- private String DBURL = "jdbc:mysql://mattie-systems.nl:3306/" + DBNAME;
- public Database()
- {
- try
- {
- // Register the JDBC driver for MySQL.
- Class.forName("com.mysql.jdbc.Driver");
- // Define URL of database server for
- // database named mysql on the localhost
- // with the default port number 3306.
- String url = DBURL;
- // Get a connection to the database for a
- // user named root with a blank password.
- // This user is the default administrator
- // having full privileges to do anything.
- con = DriverManager.getConnection(url, USERNAME, PASSWORD);
- // Display URL and connection information
- System.out.println("URL: " + url);
- System.out.println("Connection: " + con);
- // Get a Statement object
- stmt = con.createStatement();
- } catch (Exception e)
- {
- genereerCriticalError(e);
- }
- }
- public void genereerError(Exception e)// the program CAN continue
- {
- e.printStackTrace();
- }
- public void genereerCriticalError(Exception e)// the program CAN NOT continue and quits
- {
- e.printStackTrace();
- System.exit(0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment