primaryKeyName
Get the primary key's name.
- Returns:
- The table's primary key's name.
T
- The primary key's type.AutoCatchingSQLConnection
connection
to a database with built-in features for
accessing the database with proper values with primary keys, etc. <T>
as the first column and set to be the primary-key.static enum
SQLConnection(@NotNull SQLConnection.DatabaseType type,
String url,
String username,
String password,
String table,
String primaryKeyName)
SQLConnection(SQLConnection.DatabaseType type,
String ip,
int port,
String databaseName,
String username,
String password,
String table,
String primaryKeyName)
void
void
changeTable(String table)
void
boolean
void
<T2> T2
executeQuery(String sql,
Object @NotNull ... params)
<T2> T2
executeQuery(T2 def,
String sql,
Object @NotNull ... params)
@NotNull Object
@NotNull Object
list
represents
the rows and the arrays are each row's columns.getAllRowArrays(List<Object[]> def)
getAllRowMaps(List<Map<String,Object>> def)
result
of getting a row based on the primary key.result
of getting a row based on the primary key, with a default value.Object[]
getRowArray(T primaryKey)
@NotNull Object[]
getRowArray(T primaryKey,
@NotNull Object[] def)
getRowArraysContaining(Object object,
String... checkedColumns)
list
represents the rows and the arrays are each row's columns.getRowArraysContaining(List<Object[]> def,
Object object,
String... checkedColumns)
Collection<Object[]>
getRowArraysMatching(String wherePredicate,
Object @NotNull ... replacements)
list
represents the rows and the arrays are each
row's columns with their name first and then their value.@NotNull Collection<Object[]>
getRowArraysMatching(Collection<Object[]> def,
String wherePredicate,
Object @NotNull ... replacements)
@NotNull Object[]
getRowMapsContaining(Object object,
String... checkedColumns)
getRowMapsMatching(String wherePredicate,
Object @NotNull ... replacements)
collection
represents the rows and the arrays
are each row's columns with their name first and then their value.@NotNull Collection<Map<String,Object>>
getRowMapsMatching(Collection<Map<String,Object>> def,
String wherePredicate,
Object @NotNull ... replacements)
void
void
void
table()
type
- The database type.url
- The URL to the database (jdbc:type://ip:port/name)username
- Username of the account to access the database with.password
- Password of the account to access the database with.table
- The table in the database that will accessed. Can be changed later on using changeTable(String)
.primaryKeyName
- The primary key's name.SQLException
- if the connection wasn't successful, which is likely due to a wrong URL or wrong credentials.ClassNotFoundException
- if the dependency of the database type is missing.type
- The database type.ip
- The IP of the database. Can be localhost.port
- The port that the database runs on. If set to 0, will use the database type's default port
.databaseName
- The database to name, this should connect to.username
- Username of the account to access the database with.password
- Password of the account to access the database with.table
- The table in the database that will accessed. Can be changed later on using changeTable(String)
.primaryKeyName
- The primary key's name.SQLException
- if the connection wasn't successful, which is likely due to a wrong URL or wrong credentials.ClassNotFoundException
- if the dependency of the database type is missing.SQLException
- if there was an issue while closing the connection or the connection is already closed.SQLException
- if there was an error while creating the new statement.table
- The new table to get data from.T2
- The type of the result to be returned.sql
- The parameterized query to be executed.params
- The parameters that should be set into the sql query input.null
if it's empty.SQLException
- if there was an error while executing the query.T2
- The type of the result to be returned.def
- The default value if an error occurred or the result is null
.sql
- The parameterized query to be executed.params
- The parameters that should be set into the sql query input.primaryKey
- The primary key to get the row from.objects
of the row as an array
.SQLException
- if there was an error while executing the query.primaryKey
- The primary key to get the row from.objects
of the row as a map
.SQLException
- if there was an error while executing the query.result
of getting a row based on the primary key.primaryKey
- The primary key to get the row from.result
of the query.SQLException
- if there was an error while executing the query.result
of getting a row based on the primary key, with a default value.def
- The default value if an error occurred or the result is null
.primaryKey
- The primary key to get the row from.result
of the query.primaryKey
- The primary key to get the value from.column
- The column/value's name.value
in the specified field.SQLException
- if there was an error while executing the query.def
- The default value if an error occurred or the result is null
.primaryKey
- The primary key to get the value from.column
- The column/value's name.value
in the specified field.primaryKey
- The primary key to get the value from.column
- The column/value's index (starting at 1).value
in the specified field.SQLException
- if there was an error while executing the query.def
- The default value if an error occurred or the result is null
.primaryKey
- The primary key to get the value from.column
- The column/value's index (starting at 1).value
in the specified field.primaryKey
- The primary key to get the value from.column
- The column/value's name.newValue
- The new value for the specified field.SQLException
- if there was an error while executing the query.primaryKey
- The primary key to get the value from.column
- The column/value's index (starting at 1).newValue
- The new value for the specified field.SQLException
- if there was an error while executing the query.values
- All values for the new row. The keys are the column names and the values are the values.
Has to be valid according to database settings, otherwise throws an Exception
.SQLException
- if there was an error while executing the query. Can be caused by invalid values.primaryKey
- The primary key to remove.SQLException
- if there was an error while executing the query.
Can be caused by removing a non-existent row.primaryKey
- The primary key to check for.SQLException
- if there was an error while executing the query.list
represents
the rows and the arrays are each row's columns.list
containing all columns as an array.SQLException
- if there was an error while executing the query.def
- The default value if an error occurred or the result is null
.list
containing all columns as an array.list
represents the
rows and the maps
are each row's columns with their name
first and then their value.map
containing all columns with their names and values.SQLException
- if there was an error while executing the query.def
- The default value if an error occurred or the result is null
.map
containing all columns with their names and values.list
represents the rows and the arrays are each row's columns.object
- What object must be contained in at least one of the rows.checkedColumns
- All columns that are checked for the object.list
containing all columns as an array.SQLException
- if there was an error while executing the query.def
- The default value if an error occurred or the result is null
.object
- What object must be contained in at least one of the rows.checkedColumns
- All columns that are checked for the object.list
containing all columns as an array.list
represents the rows and the maps
are each row's columns
with their name first and then their value.object
- What object must be contained in at least one of the rows.checkedColumns
- All columns that are checked for the object.map
containing all columns with their names and values.SQLException
- if there was an error while executing the query.def
- The default value if an error occurred or the result is null
.object
- What object must be contained in at least one of the rows.checkedColumns
- All columns that are checked for the object.map
containing all columns with their names and values.list
represents the rows and the arrays are each
row's columns with their name first and then their value.wherePredicate
- The SQL WHERE
predicate, like column = ? AND another_column = ?
.
This is inserted right after the WHERE
.replacements
- What objects the question marks should be replaced with.SQLException
- if there was an error while executing the query or the WHERE predicate was invalid.def
- The default value if an error occurred or the result is null
.wherePredicate
- The SQL WHERE
predicate, like column = ? AND another_column = ?
.
This is inserted right after the WHERE
.replacements
- What objects the question marks should be replaced with.collection
represents the rows and the arrays
are each row's columns with their name first and then their value.wherePredicate
- The SQL WHERE
predicate, like column = ? AND another_column = ?
.
This is inserted right after the WHERE
.replacements
- What objects the question marks should be replaced with.SQLException
- if there was an error while executing the query or the WHERE predicate was invalid.def
- The default value if an error occurred or the result is null
.wherePredicate
- The SQL WHERE
predicate, like column = ? AND another_column = ?
.
This is inserted right after the WHERE
.replacements
- What objects the question marks should be replaced with.