Package com.mrivanplays.sqlhelper
Class SQLHelper
- java.lang.Object
-
- com.mrivanplays.sqlhelper.SQLHelper
-
public final class SQLHelper extends Object
Represents the heart of the library "SQLHelper".
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AlterStatementalterTable()Creates a new "ALTER" query object.voidclose()Closes the connection to the remote database.voidconnect()Connects to the remote database.CreateStatementcreate()Creates a new "CREATE TABLE IF NOT EXISTS" query object.DeleteStatementdelete()Creates a new "DELETE" query object.DropStatementdropTable()Creates a new "DROP" query object.SQLConnectionFactorygetConnectionFactory()Returns theSQLConnectionFactory, which corresponds to the specifiedConnectionTypeSet<ConnectionType>getKnownConnectionTypes()Returns an unmodifiableSet, containing all knownConnectionTypesInsertStatementinsert()Creates a new "INSERT" query object.booleanisRegistered(ConnectionType connectionType)Returns whenever the specifiedConnectionTypeis already registered.voidregisterConnectionFactory(ConnectionType connectionType, SQLConnectionFactory connectionFactory)Registers a new connection factorySelectStatementselect()Creates a new "SELECT" query object.voidsetAsyncExecutor(Executor async)Sets a newExecutorfor async queries.voidsetConnectionConfig(ConnectionConfig connectionConfig)Sets a newConnectionConfig.TruncateStatementtruncate()Creates a new "TRUNCATE" query object.UpdateStatementupdate()Creates a new "UPDATE" query object.
-
-
-
Constructor Detail
-
SQLHelper
public SQLHelper(ConnectionConfig connectionConfig, Executor async)
Creates a new instance of this class.- Parameters:
connectionConfig- connection configasync- executor for asynchronous queries. If you want them synchronous, you can specify null.
-
SQLHelper
public SQLHelper(Executor async)
-
SQLHelper
public SQLHelper()
-
-
Method Detail
-
connect
public void connect()
Connects to the remote database.
-
close
public void close()
Closes the connection to the remote database.
-
getConnectionFactory
public SQLConnectionFactory getConnectionFactory()
Returns theSQLConnectionFactory, which corresponds to the specifiedConnectionType- Returns:
- connection factory
-
registerConnectionFactory
public void registerConnectionFactory(ConnectionType connectionType, SQLConnectionFactory connectionFactory)
Registers a new connection factory- Parameters:
connectionType- the connection type you want to register a factory forconnectionFactory- the connection factory you want to register- Throws:
IllegalArgumentException- if the connection type has already a registered factory
-
isRegistered
public boolean isRegistered(ConnectionType connectionType)
Returns whenever the specifiedConnectionTypeis already registered.- Parameters:
connectionType- the connection type you want to check if its registered or not- Returns:
trueif registered,falseotherwise
-
setConnectionConfig
public void setConnectionConfig(ConnectionConfig connectionConfig)
Sets a newConnectionConfig.- Parameters:
connectionConfig- value
-
setAsyncExecutor
public void setAsyncExecutor(Executor async)
Sets a newExecutorfor async queries.- Parameters:
async- executor
-
getKnownConnectionTypes
public Set<ConnectionType> getKnownConnectionTypes()
Returns an unmodifiableSet, containing all knownConnectionTypes- Returns:
- connection types
-
select
public SelectStatement select()
Creates a new "SELECT" query object.- Returns:
- select statement
-
insert
public InsertStatement insert()
Creates a new "INSERT" query object.- Returns:
- insert statement
-
create
public CreateStatement create()
Creates a new "CREATE TABLE IF NOT EXISTS" query object.- Returns:
- create statement
-
update
public UpdateStatement update()
Creates a new "UPDATE" query object.- Returns:
- update statement
-
delete
public DeleteStatement delete()
Creates a new "DELETE" query object.- Returns:
- delete statement
-
alterTable
public AlterStatement alterTable()
Creates a new "ALTER" query object.- Returns:
- alter statement
-
dropTable
public DropStatement dropTable()
Creates a new "DROP" query object.- Returns:
- drop statement
-
truncate
public TruncateStatement truncate()
Creates a new "TRUNCATE" query object.- Returns:
- truncate statement
-
-