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 TypeMethodDescriptionboolean
Checks if a connection is open with the database.boolean
Closes the connection with the database.Gets the connection with the database.Opens a connection with the database.Executes a SQL Query.int
Executes 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:Database
Opens a connection with the database.- Specified by:
openConnection
in classDatabase
- Returns:
- Opened connection
- Throws:
SQLException
- if the connection can not be openedClassNotFoundException
- if the driver cannot be found
-
checkConnection
Description copied from class:Database
Checks if a connection is open with the database.- Specified by:
checkConnection
in classDatabase
- Returns:
true
if the connection is open- Throws:
SQLException
- if the connection cannot be checked
-
getConnection
Description copied from class:Database
Gets the connection with the database.- Specified by:
getConnection
in classDatabase
- Returns:
- Connection with the database, null if none
-
closeConnection
Description copied from class:Database
Closes the connection with the database.- Specified by:
closeConnection
in classDatabase
- Returns:
true
if successful- Throws:
SQLException
- if the connection cannot be closed
-
querySQL
Description copied from class:Database
Executes a SQL Query. If the connection is closed, it will be opened.- Specified by:
querySQL
in 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:Database
Executes an Update SQL Query. SeeStatement.executeUpdate(String)
. If the connection is closed, it will be opened.- Specified by:
updateSQL
in 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:
forceConnection
in classDatabase
- Throws:
SQLException
ClassNotFoundException
-