From 60257cab758545497c9045b648d4c4eb8f948a4a Mon Sep 17 00:00:00 2001 From: Jordyn Newnham Date: Tue, 5 Mar 2024 21:17:02 +1100 Subject: [PATCH] fix: Update README & minor documentation touchups. --- README.md | 80 ++++++++++++++++++------------------------------------- pom.xml | 12 --------- 2 files changed, 26 insertions(+), 66 deletions(-) diff --git a/README.md b/README.md index 3ba934c..904df59 100644 --- a/README.md +++ b/README.md @@ -11,19 +11,19 @@ A simple, clean and effective JDBC wrapper built on top of [HikariCP](https://gi To integrate this library in your project using maven, add these to your pom.xml ```xml - - - husk - https://maven.husk.pro/repository/maven-releases/ - + + + jitpack.io + https://jitpack.io + + ``` ```xml - - pro.husk - mysql - 1.4.2 + com.github.Huskehhh + MySQL + CHANGEME ``` @@ -33,24 +33,23 @@ Add this to repositories ```kotlin maven { - url = uri("https://maven.husk.pro/repository/maven-releases/") + url = uri("https://jitpack.io") } ``` And add this to dependencies ```kotlin -implementation("pro.husk:mysql:1.4.1") +implementation("com.github.Huskehhh:MySQL:CHANGEME") ``` -#### Note: it is assumed that mysql-connector-java is provided +#### Note: it is assumed that mysql-connector-java is provided on the classpath. If it is not, please also add For Maven ```xml - mysql mysql-connector-java @@ -66,59 +65,32 @@ implementation("mysql:mysql-connector-java:VERSION") Versions can be found [here](https://mvnrepository.com/artifact/mysql/mysql-connector-java) -#### What if I don't use a build tool - -Alternatively, you can also just compile from -source, [download a compiled version](https://github.com/Huskehhh/MySQL/actions) and add it to your classpath, or supply -the files in your project workspace! - ## Usage -### Create the database +### Instantiate the MySQL wrapper. -```Java -// Create instance -MySQL mysql=new MySQL(url,username,password); +```java +MySQL mysql = new MySQL(url, username, password); ``` ### Query -For queries, there's two different ways we can do it! - -If we are just processing data, we can do it this way (so we don't have to clean up resources later! (Recommended)) +Sync & async functions are provided, depending on your use case. -#### Sync query +#### Example sync query -```Java -// Execute query -mysql.query("SELECT * from table WHERE id = 1;",results->{ - if(results!=null){ - // do something - } - }); -``` - -...or you can get the ResultSet itself through - -```Java - try(ResultSet results=mysql.query(query)){ - // Do something with the ResultSet - - // Then close statement (the ResultSet will close itself) - results.getStatement().close(); - }catch(SQLException e){ - e.printStackTrace(); - } +```java +mysql.query("SELECT * from table WHERE id = 1;", results -> { + if (results != null) { + // Do something + } +}); ``` -Please make sure you close resources, or you'll end up with a memory leak! D: - ### Update -#### Sync update - -```Java -int resultCode=mysql.update("INSERT INTO `whitelist` (`uuid`, `date_added`) VALUES ('"+uuid+"', CURRENT_DATE());") +#### Example sync update -// Check result, do something +```java +int retval = mysql.update("INSERT INTO `whitelist` (`uuid`, `date_added`) VALUES ('"+uuid+"', CURRENT_DATE());") ``` diff --git a/pom.xml b/pom.xml index 776c729..861a6dc 100644 --- a/pom.xml +++ b/pom.xml @@ -3,26 +3,15 @@ xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - pro.husk mysql 1.4.2 jar - mysql - 11 UTF-8 - - - - husk - https://maven.husk.pro/repository/maven-releases/ - - - @@ -63,7 +52,6 @@ - mysql