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.
52ca4879f9db2ad0cc490982d9681310ec63e6d9
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
- Add the jitpack repository to your
pom.xml
<repositories> <repository> <id>jitpack.io</id> <url>https://jitpack.io</url> </repository> </repositories>
- Add the dependency to your
pom.xml
<dependency> <groupId>com.github.gnmyt</groupId> <artifactId>sqltoolkit</artifactId> <version>master-SNAPSHOT</version> </dependency>
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 optional login parameters
MySQLConnection connection = new MySQLConnection(hostname, username, password, database, LoginParam.AUTO_RECONNECT, LoginParam.NO_SSL).connect();
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 default SQL query
- Get a ResultSet
connection.getResultSet("SELECT * FROM example WHERE test = ?", "test1");
- Perform an update
connection.update("UPDATE example SET test = ? WHERE abc = ?", "test1", "test2");
- Get a ResultSet
- Get something from a table with managers
- Getting a string from the table
String value = connection.getResult("query", "parameters") .getString("column");
- Getting a list from the table
or
ArrayList<String> list = connection.getResult("query", "parameters") .getList("column");
ArrayList<HashMap<String, Object>> list = connection.getResult("query", "parameters") .getList();
- Choosing Results
connection .selectFrom("table") .where("column", "value") .limit(10) .getResult();
- Choosing Results with custom parameters
connection.select() .from("table") .where("column", "value") .add("LIMIT 2,5") .getResult();
- Getting a string from the table
- Perform an update using managers
- Update a Table
connection .updateTo("table") .where("column", "value") .set("column", "newValue") .execute();
- Generate a Table
connection .generateTable("table") .addField(SQLType.STRING, "column", 999) .addField(SQLType.STRING, "column2", 25) .create();
- Delete something from a table
connection .deleteFrom("table") .where("column", "value") .execute();
- Update a Table
You can find other examples in the examples directory.
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%