Package com.plotsquared.core.database
Class SQLite
java.lang.Object
com.plotsquared.core.database.Database
com.plotsquared.core.database.SQLite
Connects to and uses a SQLite database.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanChecks if a connection is open with the database.booleanCloses the connection with the database.Gets the connection with the database.Opens a connection with the database.Executes a SQL Query.intExecutes an Update SQL Query.
-
Constructor Details
-
SQLite
Creates a new SQLite instance- Parameters:
dbLocation- Location of the Database (Must end in .db)
-
-
Method Details
-
openConnection
Description copied from class:DatabaseOpens a connection with the database.- Specified by:
openConnectionin classDatabase- Returns:
- Opened connection
- Throws:
SQLException- if the connection can not be openedClassNotFoundException- if the driver cannot be found
-
checkConnection
Description copied from class:DatabaseChecks if a connection is open with the database.- Specified by:
checkConnectionin classDatabase- Returns:
- true if the connection is open
- Throws:
SQLException- if the connection cannot be checked
-
getConnection
Description copied from class:DatabaseGets the connection with the database.- Specified by:
getConnectionin classDatabase- Returns:
- Connection with the database, null if none
-
closeConnection
Description copied from class:DatabaseCloses the connection with the database.- Specified by:
closeConnectionin classDatabase- Returns:
- true if successful
- Throws:
SQLException- if the connection cannot be closed
-
querySQL
Description copied from class:DatabaseExecutes a SQL Query. If the connection is closed, it will be opened.- Specified by:
querySQLin classDatabase- Parameters:
query- Query to be run- Returns:
- the results of the query
- Throws:
SQLException- If the query cannot be executedClassNotFoundException- If the driver cannot be found; seeDatabase.openConnection()
-
updateSQL
Description copied from class:DatabaseExecutes an Update SQL Query. SeeStatement.executeUpdate(String). If the connection is closed, it will be opened.- Specified by:
updateSQLin classDatabase- Parameters:
query- Query to be run- Returns:
- Result Code, see
Statement.executeUpdate(String) - Throws:
SQLException- If the query cannot be executedClassNotFoundException- If the driver cannot be found; seeDatabase.openConnection()
-
forceConnection
- Specified by:
forceConnectionin classDatabase- Throws:
SQLExceptionClassNotFoundException
-