Package dev.array21.jdbd.drivers
Class MysqlDriver
java.lang.Object
dev.array21.jdbd.drivers.MysqlDriver
- All Implemented Interfaces:
DatabaseDriver
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedMysqlDriver(String host, String username, String password, String database) Create a new MysqlDriver -
Method Summary
Modifier and TypeMethodDescriptionvoidexecute(PreparedStatement statement) Execute aPreparedStatementbooleanisLoaded()Check if the driver is loaded.voidLoad the native driverSqlRow[]query(PreparedStatement statement) Query the MySQL databasevoidunload()Unload the driver
-
Constructor Details
-
MysqlDriver
Create a new MysqlDriverThread Safety
It is up to the implementer to guarantee that this method is NOT called from two threads simultaneously, this can result in Undefined Behaviour- Parameters:
host- The MySQL hostusername- The MySQL usernamepassword- The MySQL passworddatabase- The MySQL database
-
-
Method Details
-
loadDriver
Load the native driver- Throws:
IOException- When saving the native library failedUnsatisfiedLinkError- When loading the native library failedUnsupportedOperatingSystemException- When the current operating system is unsupportedRuntimeException- WheninitializeNative()returns an error
-
isLoaded
public boolean isLoaded()Check if the driver is loaded. When:- The library is loaded
- The driver has been initialized
- Returns:
- True if it is loaded, false otherwhise
-
query
Query the MySQL database- Specified by:
queryin interfaceDatabaseDriver- Parameters:
statement- The statement to query with- Throws:
IllegalStateException- When the native library is not loadedDriverUnloadedException- Whenunload()has already been calledUnboundPreparedStatementException- When not all parameters in the statement have been boundSQLExceptionSqlException
-
execute
Execute aPreparedStatement- Specified by:
executein interfaceDatabaseDriver- Parameters:
statement- The statemenent to execute- Throws:
IllegalStateException- When the native library is not loadedDriverUnloadedException- Whenunload()has already been calledUnboundPreparedStatementException- When not all parameters in the statement have been boundSqlException
-
unload
public void unload()Unload the driver- Specified by:
unloadin interfaceDatabaseDriver- Throws:
IllegalStateException- When the native library is not loadedDriverUnloadedException- Whenunload()has already been called
-