Git Product home page Git Product logo

mysql's Introduction

A simple JDBC wrapper

Java CI with Gradle

A simple, clean and effective JDBC wrapper built on top of HikariCP

Setting up your project workspace

Maven

To integrate this library in your project using maven, add these to your pom.xml

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
<dependency>
    <groupId>com.github.Huskehhh</groupId>
    <artifactId>MySQL</artifactId>
    <version>CHANGEME</version>
</dependency>

Gradle

Add this to repositories

maven {
    url = uri("https://jitpack.io")
}

And add this to dependencies

implementation("com.github.Huskehhh:MySQL:CHANGEME")

Note: it is assumed that mysql-connector-java is provided on the classpath.

If it is not, please also add

For Maven

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>VERSION</version>
</dependency>

or for Gradle

implementation("mysql:mysql-connector-java:VERSION")

Versions can be found here

Usage

Instantiate the MySQL wrapper.

MySQL mysql = new MySQL(url, username, password);

Query

Sync & async functions are provided, depending on your use case.

Example sync query

mysql.query("SELECT * from table WHERE id = 1;", results -> {
    if (results != null) {
        // Do something
    }
});

Update

Example sync update

int retval = mysql.update("INSERT INTO `whitelist` (`uuid`, `date_added`) VALUES ('"+uuid+"', CURRENT_DATE());")

mysql's People

Contributors

benhall-1 avatar gomorrhadev avatar hawkfalcon avatar huskehhh avatar ktar5 avatar rowedahelicon avatar tips48 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mysql's Issues

Public Key Retrieval is not allowed

When I try to connect into database it give me Public Key Retrieval is not allowed error.

I know that I can solve this problem by removing useSSL = false or adding option allowPublicKeyRetrieval=true, but I can't remove any parameter from pro.husk.mysql.MySQL Object or add any option.

MySQL Lite

SQLite.java, line 50: getDataFolder().toPath() should be getDataFolder().getPath()

Too many connections

when i reload the minecraft server the HikariPool create a new pool connection. However when it arrives at the 20th connection, i get an error. This error: "Too many connections"
image

My code of start and disable mysql:

    private void disableMySQL() {
      try {
         if (mysql != null) {
            mysql.closeConnection();
         }
      } catch (SQLException var2) {
         var2.printStackTrace();
      } 
    }

    private void startMySQL() {
        if (this.getConfig().getBoolean("mysql.enable")) {
           String url = "jdbc:mysql://" + this.getConfig().getString("mysql.host") + ":" + this.getConfig().getString("mysql.port") + "/" + this.getConfig().getString("mysql.database") + "/" + this.getConfig().getString("mysql.username") + "/" + this.getConfig().getString("mysql.password");
           mysql = new MySQL("jdbc:mysql://" + this.getConfig().getString("mysql.host") + ":" + this.getConfig().getString("mysql.port") + "/" + this.getConfig().getString("mysql.database"), this.getConfig().getString("mysql.username"), this.getConfig().getString("mysql.password"));
        }
     }

image

TLS 1.2 disabled maven repo

I'm getting failing building from my Travis builds, 1.8 java.

Failed to execute goal on project Parkour: Could not resolve dependencies for project io.github.a5h73y:Parkour:jar:6.0: Failed to collect dependencies at pro.husk:mysql:jar:1.4.0: Failed to read artifact descriptor for pro.husk:mysql:jar:1.4.0: Could not transfer artifact pro.husk:mysql:pom:1.4.0 from/to husk (https://maven.husk.pro/repository/maven-public/): Received fatal alert: protocol_version -> [Help 1]

Access Denied

When I or dependabot try to access the maven repo I get access denied

Can I create a pool of connections?

Maybe that's a stupid question, but I'm new to this topic.
I heard that using a pool of MySQL connections is more efficient if you have a lot of requests.
I saw a few examples of pools, which I didn't really understand, so
can I use this wrapper to create a connection pool easily?

Maven repo offline

Hey,

I just noticed that the project cannot be used as your maven server (maven.husk.pro) is offline.

Communications link failure

Hey, currently getting this issue when I try to connect to my database...

com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Communications link failure at com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:589) at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:575) at com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:115) at com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81) at pro.husk.mysql.MySQL.<init>(MySQL.java:68) at codes.benh.XXX.XXX.main(XXX.java:25) Caused by: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure at com.mysql.cj.jdbc.exceptions.SQLError.createCommunicationsException(SQLError.java:174) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:64) at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:836) at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:456) at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:246) at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:197) at com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:138) at com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:354) at com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:202) at com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:473) at com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:554) ... 4 more Caused by: com.mysql.cj.exceptions.CJCommunicationsException: Communications link failure at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:105) at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:151) at com.mysql.cj.exceptions.ExceptionFactory.createCommunicationsException(ExceptionFactory.java:167) at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:338) at com.mysql.cj.protocol.a.NativeAuthenticationProvider.negotiateSSLConnection(NativeAuthenticationProvider.java:777) at com.mysql.cj.protocol.a.NativeAuthenticationProvider.proceedHandshakeWithPluggableAuthentication(NativeAuthenticationProvider.java:486) at com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:202) at com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1340) at com.mysql.cj.NativeSession.connect(NativeSession.java:157) at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:956) at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826) ... 12 more Caused by: javax.net.ssl.SSLHandshakeException: Remote host terminated the handshake at java.base/sun.security.ssl.SSLSocketImpl.handleEOF(SSLSocketImpl.java:1321) at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1160) at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1063) at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:402) at com.mysql.cj.protocol.ExportControlled.performTlsHandshake(ExportControlled.java:336) at com.mysql.cj.protocol.StandardSocketFactory.performTlsHandshake(StandardSocketFactory.java:188) at com.mysql.cj.protocol.a.NativeSocketConnection.performTlsHandshake(NativeSocketConnection.java:99) at com.mysql.cj.protocol.a.NativeProtocol.negotiateSSLConnection(NativeProtocol.java:329) ... 19 more Caused by: java.io.EOFException: SSL peer shut down incorrectly at java.base/sun.security.ssl.SSLSocketInputRecord.decodeInputRecord(SSLSocketInputRecord.java:239) at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:190) at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:108) at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1152) ... 25 more

Initialising it with this:
sql = new MySQL("192.168.1.XXX", "3306", "XXX", "XXX", "XXX", "");

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.