コード例 #1
0
 /**
  * parameterized constructor used for MySql database servers running on the default port. will
  * construct a connection string and connect to the database.
  *
  * @param addr - server address
  * @param database - database name
  * @param user - username
  * @param pass - password for the username
  */
 public DBConnection(String addr, String database, String user, String pass) {
   setAddress(addr);
   setDBName(database);
   setUserName(user);
   setPassword(pass);
   buildConnString();
   connect();
 }
コード例 #2
0
 /**
  * Overloaded constructor used to connect to a default server set up w/a specific password
  *
  * @param pass - Password from the user
  * @param DB - Database to connect to, blank connects to the server and no database
  * @author L. Duke
  */
 public DBConnection(String db, String pass) {
   setAddress("localhost");
   setPort("3306");
   setDBName(db);
   setUserName("root");
   setPassword(pass);
   buildConnString();
   connect();
 }