Class Database.DatabaseBuilder
java.lang.Object
com.github.tadukoo.database.mysql.Database.DatabaseBuilder
- All Implemented Interfaces:
Database.Build,Database.DatabaseNameOrUsername,Database.Host,Database.Logger,Database.MaxAttemptsOrBuild,Database.Password,Database.PortOrDatabaseNameOrUsername,Database.Username
- Enclosing class:
- Database
public static class Database.DatabaseBuilder
extends Object
implements Database.Logger, Database.Host, Database.PortOrDatabaseNameOrUsername, Database.DatabaseNameOrUsername, Database.Username, Database.Password, Database.MaxAttemptsOrBuild, Database.Build
A Builder to use to build a
Database. It takes the following parameters:
| Parameter | Description | Default or Required |
|---|---|---|
| logger | The logger to use for logging |
Required |
| host | The MySQL host url | Required |
| port | The MySQL host port | Defaults to 3306 |
| databaseName | The MySQL host database name | Defaults to null (used e.g. when creating the database on the server) |
| username | The MySQL username for connecting to the Database | Required |
| password | The MySQL password for connecting to the Database | Required, may be the empty string for a blank password |
| maxAttempts | The maximum number of attempts to try a SQL transaction before giving up | Defaults to 10 |
- Version:
- Alpha v.0.3
- Author:
- Logan Ferree (Tadukoo)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringThe MySQL host database nameprivate StringThe MySQL host urlprivate com.github.tadukoo.util.logger.EasyLoggerTheloggerto use for loggingprivate intThe maximum number of attempts to try a SQL transaction before giving upprivate StringThe MySQL password for connecting to the Databaseprivate intThe MySQL host portprivate StringThe MySQL username for connecting to the Database -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateNot allowed to instantiate outside of Database -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a newDatabasewith the set parametersprivate voidChecks for any errors with the set parameters and will throw an IllegalArgumentException if any are founddatabaseName(String databaseName) logger(com.github.tadukoo.util.logger.EasyLogger logger) maxAttempts(int maxAttempts) port(int port)
-
Field Details
-
logger
private com.github.tadukoo.util.logger.EasyLogger loggerTheloggerto use for logging -
host
The MySQL host url -
port
private int portThe MySQL host port -
databaseName
The MySQL host database name -
username
The MySQL username for connecting to the Database -
password
The MySQL password for connecting to the Database -
maxAttempts
private int maxAttemptsThe maximum number of attempts to try a SQL transaction before giving up
-
-
Constructor Details
-
DatabaseBuilder
private DatabaseBuilder()Not allowed to instantiate outside of Database
-
-
Method Details
-
logger
- Specified by:
loggerin interfaceDatabase.Logger- Parameters:
logger- Theloggerto use for logging- Returns:
- this, to continue building
-
host
- Specified by:
hostin interfaceDatabase.Host- Parameters:
host- The MySQL host url- Returns:
- this, to continue building
-
port
- Specified by:
portin interfaceDatabase.PortOrDatabaseNameOrUsername- Parameters:
port- The MySQL host port- Returns:
- this, to continue building
-
databaseName
- Specified by:
databaseNamein interfaceDatabase.DatabaseNameOrUsername- Parameters:
databaseName- The MySQL host database name- Returns:
- this, to continue building
-
username
- Specified by:
usernamein interfaceDatabase.Username- Parameters:
username- The MySQL username for connecting to the database- Returns:
- this, to continue building
-
password
- Specified by:
passwordin interfaceDatabase.Password- Parameters:
password- The MySQL password for connecting to the database- Returns:
- this, to continue building
-
maxAttempts
- Specified by:
maxAttemptsin interfaceDatabase.MaxAttemptsOrBuild- Parameters:
maxAttempts- The maximum amount of attempts to try a SQL transaction before giving up- Returns:
- this, to continue building
-
checkForErrors
private void checkForErrors()Checks for any errors with the set parameters and will throw an IllegalArgumentException if any are found -
build
Builds a newDatabasewith the set parameters- Specified by:
buildin interfaceDatabase.Build- Returns:
- The newly built
Database
-