public class MySQL extends Database
Constructor and Description |
---|
MySQL(org.bukkit.plugin.Plugin plugin,
java.lang.String hostname,
java.lang.String port,
java.lang.String database,
java.lang.String username,
java.lang.String password)
Creates a new MySQL instance
|
Modifier and Type | Method and Description |
---|---|
boolean |
checkConnection()
Checks if a connection is open with the database
|
boolean |
closeConnection()
Closes the connection with the database
|
java.sql.Connection |
getConnection()
Gets the connection with the database
|
java.sql.Connection |
openConnection()
Opens a connection with the database
|
java.sql.ResultSet |
querySQL(java.lang.String query)
Executes a SQL Query
If the connection is closed, it will be opened |
int |
updateSQL(java.lang.String query)
Executes an Update SQL Query
See Statement.executeUpdate(String) If the connection is closed, it will be opened |
public MySQL(org.bukkit.plugin.Plugin plugin, java.lang.String hostname, java.lang.String port, java.lang.String database, java.lang.String username, java.lang.String password)
plugin
- Plugin instancehostname
- Name of the hostport
- Port numberdatabase
- Database nameusername
- Usernamepassword
- Passwordpublic java.sql.Connection openConnection() throws java.sql.SQLException, java.lang.ClassNotFoundException
Database
openConnection
in
class Database
java.sql.SQLException
- if the connection can not be openedjava.lang.ClassNotFoundException
- if the driver cannot be foundpublic boolean checkConnection() throws java.sql.SQLException
Database
checkConnection
in
class Database
java.sql.SQLException
- if the connection cannot be checkedpublic java.sql.Connection getConnection()
Database
getConnection
in
class Database
public boolean closeConnection() throws java.sql.SQLException
Database
closeConnection
in
class Database
java.sql.SQLException
- if the connection cannot be closedpublic java.sql.ResultSet querySQL(java.lang.String query) throws java.sql.SQLException, java.lang.ClassNotFoundException
Database
querySQL
in
class Database
query
- Query to be runjava.sql.SQLException
- If the query cannot be executedjava.lang.ClassNotFoundException
- If the driver cannot be found; see
Database.openConnection()
public int updateSQL(java.lang.String query) throws java.sql.SQLException, java.lang.ClassNotFoundException
Database
Statement.executeUpdate(String)
updateSQL
in
class Database
query
- Query to be runStatement.executeUpdate(String)
java.sql.SQLException
- If the query cannot be executedjava.lang.ClassNotFoundException
- If the driver cannot be found; see
Database.openConnection()