import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
+import java.text.MessageFormat;
import java.util.Iterator;
import org.mxchange.addressbook.contact.Contact;
import org.mxchange.addressbook.database.backend.BaseDatabaseBackend;
// Validate driver
this.validateDriver("mysql"); //NOI18N
- // Now that the driver is there ...
+ // Now that the driver is there, set the table name
+ this.setTableName(tableName);
}
@Override
public void connectToDatabase () throws SQLException {
+ // Trace message
+ this.getLogger().trace("CALLED!");
+
// Generate connection string
- String connect = "jdbc:mysql://" + this.getProperty("org.mxchange.database.mysql.host") + "/" + this.getTableName();
+ String connect = String.format("jdbc:mysql://%s/%s", this.getProperty("org.mxchange.addressbook.database.mysql.host"), this.getProperty("org.mxchange.addressbook.database.mysql.dbname"));
+
+ // Debug message
+ this.getLogger().debug(MessageFormat.format("Attempting to connect to {0} ...", connect));
// Now get a connection instance back
- this.connection = DriverManager.getConnection(connect, this.getProperty("org.mxchange.database.mysql.login"), this.getProperty("org.mxchange.database.mysql.password"));
+ this.connection = DriverManager.getConnection(connect, this.getProperty("org.mxchange.addressbook.database.mysql.login"), this.getProperty("org.mxchange.addressbook.database.mysql.password"));
+
+ // Trace message
+ this.getLogger().trace("EXIT!");
}
@Override