All source projects
MrUltimateLibrary Source
Standalone source project / 68 files
MrUltimateLibrary is the backbone of all my plugins; it offers features that facilitate plugin creation, maintenance, and updates.
java
MrUltimateLibrary/src/main/java/eu/mrneznamy/mrultimatelibrary/database/MrLibDatabase.java
JAVA · Read-only source
package eu.mrneznamy.mrultimatelibrary.database;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.function.Consumer;
/**
* Database interface for MySQL and SQLite
*/
public interface MrLibDatabase {
/**
* Connect to database
*
* @return true if successful
*/
boolean connect();
/**
* Disconnect from database
*/
void disconnect();
/**
* Check if connected
*/
boolean isConnected();
/**
* Get connection
*/
Connection getConnection();
/**
* Execute update (INSERT, UPDATE, DELETE)
*
* @param sql SQL query
* @param params Parameters
* @return Number of affected rows
*/
int executeUpdate(String sql, Object... params);
/**
* Execute query (SELECT)
*
* @param sql SQL query
* @param callback Result handler
* @param params Parameters
*/
void executeQuery(String sql, Consumer<ResultSet> callback, Object... params);
/**
* Execute query and return result
*
* @param sql SQL query
* @param params Parameters
* @return ResultSet or null
*/
ResultSet executeQuerySync(String sql, Object... params);
/**
* Create table if not exists
*
* @param tableName Table name
* @param columns Columns definition
*/
void createTable(String tableName, String columns);
/**
* Check if table exists
*
* @param tableName Table name
* @return true if exists
*/
boolean tableExists(String tableName);
}
80 linesGNU GENERAL PUBLIC LICENSE · Version 3, 29 June 2007 · UTF-8 · Read only