Skip to content

[FORKED] MariaDB Connector/J is used to connect applications developed in Java to MariaDB and MySQL databases.

License

Notifications You must be signed in to change notification settings

mping-exo/mariadb-connector-j

 
 

Repository files navigation

MariaDB java connector Build Guide

For general introduction for MariaDB java connector, please check on https://github.com/MariaDB/mariadb-connector-j . The source code here is in the latest version same with the master branch on https://github.com/MariaDB/mariadb-connector-j with redirection feature support. Following is a brief guide of how to build and test the driver.

MariaDB version

Tools prerequisite to build the drivers

  • Java 1.8+
  • Maven

Step to build

  • Assuming the code directory is mariadb-connector-j
  • Git clone https://github.com/Microsoft/mariadb-connector-j
  • cd mariadb-connector-j
  • mvn package, If you want to build without running unit tests, use mvn -Dmaven.test.skip=true package Otherwise, the default test database names is testj, user root without password. You can also specify the connection string as follows: mvn -DdbUrl=jdbc:mariadb://localhost:3306/testj?user=root&password=xxx -DlogLevel=FINEST package

After that, you should have JDBC jar mariadb-java-client-x.y.z.jar in the 'target' subdirectory.

Step to test

    // Load the JDBC driver
    Class.forName("org.mariadb.jdbc.Driver");
    System.out.println("Driver loaded");

    int count = 10;
    String query = "SELECT 1";
    int i=0;
    // Try to connect
    String url = "jdbc:mysql://xxx.mysql.database.azure.com"+
            "?verifyServerCertificate=false"+
            "&useSSL=true"+
            "&requireSSL=true" +
			"&enableRedirect=true";

    Connection connection = DriverManager.getConnection (url, "username", "password");
    double t1 = System.nanoTime();
    Statement s1 = connection.createStatement();
    for(i=0;i<count;i++)
    {
        s1.executeQuery(query);
    }
    double t2 = System.nanoTime();
    System.out.println (" time = " + (t2 - t1)/count/1000000);
    connection.close();

About

[FORKED] MariaDB Connector/J is used to connect applications developed in Java to MariaDB and MySQL databases.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 99.3%
  • Other 0.7%