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
Modifier and TypeFieldDescriptionprivate String
The MySQL host database nameprivate String
The MySQL host urlprivate com.github.tadukoo.util.logger.EasyLogger
Thelogger
to use for loggingprivate int
The maximum number of attempts to try a SQL transaction before giving upprivate String
The MySQL password for connecting to the Databaseprivate int
The MySQL host portprivate String
The MySQL username for connecting to the Database -
Constructor Summary
ModifierConstructorDescriptionprivate
Not allowed to instantiate outside of Database -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Builds a newDatabase
with the set parametersprivate void
Checks 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 loggerThelogger
to 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:
logger
in interfaceDatabase.Logger
- Parameters:
logger
- Thelogger
to use for logging- Returns:
- this, to continue building
-
host
- Specified by:
host
in interfaceDatabase.Host
- Parameters:
host
- The MySQL host url- Returns:
- this, to continue building
-
port
- Specified by:
port
in interfaceDatabase.PortOrDatabaseNameOrUsername
- Parameters:
port
- The MySQL host port- Returns:
- this, to continue building
-
databaseName
- Specified by:
databaseName
in interfaceDatabase.DatabaseNameOrUsername
- Parameters:
databaseName
- The MySQL host database name- Returns:
- this, to continue building
-
username
- Specified by:
username
in interfaceDatabase.Username
- Parameters:
username
- The MySQL username for connecting to the database- Returns:
- this, to continue building
-
password
- Specified by:
password
in interfaceDatabase.Password
- Parameters:
password
- The MySQL password for connecting to the database- Returns:
- this, to continue building
-
maxAttempts
- Specified by:
maxAttempts
in 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 newDatabase
with the set parameters- Specified by:
build
in interfaceDatabase.Build
- Returns:
- The newly built
Database
-