This repository has been archived on 2025-03-19 . You can view files and clone it, but cannot push or open issues or pull requests.
MySQL Toolkit
About The Project
This is a small project for quickly managing a MySQL database in Java. It makes everyday life with a database much easier.
Installation
- Clone the repo
git clone https://github.com/gnmyt/sqltoolkit.git
- Move the project into a package of your project (in most cases "sql")
- Ready! Have fun
Maven coming soon
Usage Examples
- Create a connection
- Example of a constructor without optional specifications
MySQLConnection connection = new MySQLConnection(hostname, username, password, database).connect();
- Example of a constructor with setting the logging level
MySQLConnection connection = new MySQLConnection(hostname, username, password, database, LogLevelType.ALL).connect();
- Example of a constructor with optional login parameters
MySQLConnection connection = new MySQLConnection(hostname, username, password, database, LoginParam.AUTO_RECONNECT, LoginParam.NO_SSL).connect();
Logging Levels
- NONE - Sends nothing
- LOW - Sends Warnings & Errors
- ALL - Sends Infos, Warnings & Errors
Login Parameters
- DEFAULT (useSSL=false&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&useTimezone=true&serverTimezone=UTC)
- NO_SSL (useSSL=false)
- USE_SSL (useSSL=true)
- AUTO_RECONNECT (autoReconnect=true)
- UTF8_ENCODING (characterEncoding=UTF-8)
- USE_UNICODE (useUnicode=yes)
- USE_TIMEZONE (useTimezone=true)
- TIMEZONE_UTC (serverTimezone=UTC)
- Perform a standard SQL query
- Get a ResultSet
connection.getResultSet("default query", "parameters");
- Perform an update
connection.update("query", "parameters");
- Get a ResultSet
- Get something from a table with managers
- Getting a Result (For one result)
String value = connection.getResult("query", "parameters") .getString("column");
- Getting Results (For more than one)
ArrayList<String> list = connection.getResult("query", "parameters") .getList("column");
- Choosing Results
connection .selectFrom("table") .where("column", "value") .limit(10) .getResult();
- Choosing Results + Print the current statement
connection.select() .from("table") .where("column", "value") .add("LIMIT 2,5") .printStatement();
- Getting a Result (For one result)
- Perform an update using managers
- Update a Table
connection .update() .toTable("table") .where("column", "value") .set("column", "newValue") .update();
- Generate a Table
connection .update() .generateTable("table") .useID() .addField(new SQLField(SQLType.STRING, "column", 999)) .addField(new SQLField(SQLType.STRING, "column2", 25)) .create();
- Update a Table
License
Distributed under the MIT License. See LICENSE
for more information.
End
Currently there are not many features yet, so feel free to write me some suggestions!
Release v2.0.1
Latest
Languages
Java
100%