Giter Club home page Giter Club logo

mariadb4j's Introduction

Please ⭐ Star on GitHub and 💸 support on OpenCollective, via GitHub Sponsoring or through a Tidelift subscription to ensure active maintenance of this project used by hundreds, since 2011! 🫶

What?

MariaDB4j is a Java (!) "launcher" for MariaDB (the "backward compatible, drop-in replacement of the MySQL® Database Server", see Wikipedia), allowing you to use MariaDB (MySQL®) from Java without ANY installation / external dependencies. Read again: You do NOT have to have MariaDB binaries installed on your system to use MariaDB4j!

PayPal donate button Patreon me! Maven Central Javadocs JitPack Build Status pre-commit.ci status OpenSSF Scorecard OpenSSF Best Practices

How? (Java)

The MariaDB native binaries are in the MariaDB4j-DB-win*/linux*/mac*.JARs on which the main MariaDB4j JAR depends on by Maven transitive dependencies and, by default, are extracted from the classpath to a temporary base directory on the fly, then started by Java.

An example of this can be found in the source tree, in MariaDB4jSampleTutorialTest.java. Basically, you can simply:

  1. Install the database with a particular configuration, using short-cut:

    DB db = DB.newEmbeddedDB(3306);
  2. (Optional) The data directory will, by default, be in a temporary directory too, and will automatically get scratched at every restart; this is suitable for integration tests. If you use MariaDB4j for something more permanent (maybe an all-in-one application package?), then you can simply specify a more durable location of your data directory in the DBConfiguration, like so:

    DBConfigurationBuilder configBuilder = DBConfigurationBuilder.newBuilder();
    configBuilder.setPort(3306); // OR, default: setPort(0); => autom. detect free port
    configBuilder.setDataDir("/home/theapp/db"); // just an example
    DB db = DB.newEmbeddedDB(configBuilder.build());
  3. Start the database

    db.start();
  4. Use the database as per standard JDBC usage. In this example, you're acquiring a JDBC Connection from the DriverManager; note that you could easily configure this URL to be used in any JDBC connection pool. MySQL uses a test database by default, and a root user with no password is also a default.

    Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/test", "root", "");

    A similar suitable JDBC URL as String can normally also be directly obtained directly from the MariaDB4j API, if you prefer (this is especially useful for tests if you let MariaDB4j automatically choose a free port, in which case a hard-coded URL is problematic):

    Connection conn = DriverManager.getConnection(configBuilder.getURL(dbName), "root", "");
  5. If desired, load data from a SQL resource, located in the classpath:

    db.source("path/to/resource.sql");

If you would like to / need to start a specific DB version you already have, instead of the version currently packaged in the JAR, you can use DBConfigurationBuilder setUnpackingFromClasspath(false) & setBaseDir("/my/db/") or -DmariaDB4j.unpack=false -DmariaDB4j.baseDir=/home/you/stuff/myFavouritemMariadDBVersion. Similarly, you can also pack your own version in a JAR and put it on the classpath, and @Override getBinariesClassPathLocation() in DBConfigurationBuilder to return where to find it (check the source of the default implementation).

How (using existing native MariaDB binaries)

MariaDB4j supports using existing native MariaDB binaries on the host system rather than unpacking MariaDB from the classpath. This is useful if you need a newer version than is currently distributed, or e.g. for Mac M1/M2. You can control this via the DBConfigurationBuilder:

import static ch.vorburger.mariadb4j.DBConfiguration.Executable.Server;
import ch.vorburger.mariadb4j.DBConfigurationBuilder;

DBConfigurationBuilder config = DBConfigurationBuilder.newBuilder();
config.setPort(0); // 0 => autom. detect free port
config.setUnpackingFromClasspath(false);
config.setLibDir(System.getProperty("java.io.tmpdir") + "/MariaDB4j/no-libs");

// On Linux it may be necessary to set both the base dir and the server executable
// as the `mysqld` binary lives in `/usr/sbin` rather than `/usr/bin`
config.setBaseDir("/usr");
config.setExecutable(Server, "/usr/sbin/mysqld");

// On MacOS with MariaDB installed via homebrew, you can just set base dir to the output of `brew --prefix`
config.setBaseDir("/usr/local") // or "/opt/homebrew" for M1 Macs

How (Spring)

MariaDB4j can be used in any Java Application on its own. It is not dependent on dependency injection or the Spring Framework (the dependency to the spring-core*.jar is for a utility, and is unrelated to DI).

If you want to use MariaDB4j with Spring-boot the opinionated presets for spring applications, then you can easily use this the ready-made MariaDB4jSpringService to reduce your coding/configuration to get you going, we have an example application (mariaDB4j-app) which illustrates how to wire it up or as an alternative approach via the MariaDB4jSpringServiceTestSpringConfiguration.

The DataSource initialization have to wait until MariaDB is ready to receive connections, so we provide mariaDB4j-springboot to implement it. You can use it by :

dependencies {
   testCompile("ch.vorburger.mariaDB4j:mariaDB4j-springboot:3.1.0")
}

In the module, bean name of MariaDB4jSpringService is mariaDB4j, and dataSource depends on it by name. So if you want to customize your mariaDB4j, please make sure the name is correctly.

In issue #64 there is also a discussion about it and pointing to a TestDbConfig.java gist.

How (CLI)

Because the MariaDB4j JAR is executable, you can also quickly fire up a database from a command line interface:

java [-DmariaDB4j.port=3718] [-DmariaDB4j.baseDir=/home/theapp/bin/mariadb4j] [-DmariaDB4j.dataDir=/home/theapp/db] -jar mariaDB4j-app*.jar

Note the use of the special mariaDB4j-app*.jar for this use-case, its a fat/shaded/über-JAR, based on a Spring Boot launcher.

Where from?

MariaDB4j JAR binaries are available from:

  1. Maven central:

    <dependency>
        <groupId>ch.vorburger.mariaDB4j</groupId>
        <artifactId>mariaDB4j</artifactId>
        <version>3.1.0</version>
    </dependency>
  2. https://jitpack.io: main-SNAPSHOT, releases, see also issue #41 discussion

  3. Not Bintray! (Up to version 2.1.3 MariaDB4j was on Bintray. Starting with version 2.2.1 we’re only using Maven central. The 2.2.1 that is on Bintray is broken.)

  4. Local build: For bleeding edge -SNAPSHOT versions, you (or your build server) can easily build it yourself from source; just git clone this repo, and then ./mvnw install (or deploy) it. -- MariaDB4j's Maven then coordinates are:

Database Maven Artifacts

If you use your own packaged versions of MariaDB native binaries, then the mariaDB4j-core artifact JAR, which contains only the launcher Java code but no embedded native binaries, will be more suitable for you.

You can also exclude one of artifacts of the currently 3 packaged OS platform to save download if your project / community is mono-platform.

You could also override the version(s) of the respective (transitive) mariaDB4j-db-* dependency to downgrade it, and should so be able to use the latest mariaDB4j-core artifact JARs, even with older`versions of the JAR archives containing the native mariaDB executables etc. This may be useful if your project for some reason needs a fixed older DB version, but wants to get the latest MariaDB4j launcher Java code.

Release Notes

Release Notes are in CHANGES.md.

Why?

Being able to start a database without any installation / external dependencies is useful in a number of scenarios, such as all-in-one application packages, or for running integration tests without depending on the installation, set-up and up-and-running of an externally managed server. You could also use this easily run some DB integration tests in parallel but completely isolated, as the MariaDB4j API explicitly support this.

Java developers frequently use pure Java databases such as H2, hsqldb (HyperSQL), Derby / JavaDB for this purpose. This library brings the advantage of the installation-free DB approach, while maintaining MariaDB (and thus MySQL) compatibility.

Who's using it?

MariaDB4j was initially developed for use in Mifos, the "Open Source Technology that accelerates Microfinance", see http://mifos.org. Coincidentally, OpenMRS the "Open Source Medical Records System" (see http://openmrs.org), another Humanitarian Open Source (HFOSS) project, also uses MariaDB4j (see https://github.com/vorburger/MariaDB4j/pull/1).

See the USERS.md file (also included in each built JAR!) for a list of publicly known users.

Do send a PR adding your name/organization to USERS.md to show your appreciation for this free project!

Maven Plugin Info (mariadb4j-maven-plugin)

Maven plugin that starts and stops a MariaDB instance for the integration test phase.

This is a Maven plugin wrapper around https://github.com/vorburger/MariaDB4j, a helpful tool for launching MariaDB from Java.

See pom and integration test in https://github.com/vorburger/MariaDB4j/tree/mariaDB4j-maven-plugin/mariaDB4j-maven-plugin/src/it/mariadb4j-maven-plugin-test-basic for usage example.

Example usage

An example usage of this plugin is to install and start a database at the start of the integration test phase, and stop and uninstall the database afterwards.

This is done by configuring the plugin to execute the start goal in the pre-integration-test phase and the stop goal in the post-integration-test phase:

<plugin>
  <groupId>ch.vorburger.mariaDB4j</groupId>
  <artifactId>mariaDB4j-maven-plugin</artifactId>
  ...
  <executions>
    <execution>
      <id>pre-integration-test</id>
      <goals>
        <goal>start</goal>
      </goals>
    </execution>
    <execution>
      <id>post-integration-test</id>
      <goals>
        <goal>stop</goal>
      </goals>
    </execution>
  </executions>
</plugin>

This will ensure there is a MariaDB instance running on a random port, and expose the database URL as a Maven Project property.

To access the database in your integration tests, you can pass the database URL as system property to your integration tests:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-failsafe-plugin</artifactId>
  ...
  <configuration>
    <systemProperties>
      <mariadb.databaseurl>${mariadb4j.databaseurl}</mariadb.databaseurl>
    </systemProperties>
  </configuration>
</plugin>

How to upgrade the maven plugin from mike10004 version to this version

To upgrade from mike10004 to vorbuger version please change

<plugin>
    <groupId>com.github.mike10004</groupId>
    <artifactId>mariadb4j-maven-plugin</artifactId>
    ...
</plugin>

to

<plugin>
    <groupId>ch.vorburger.mariaDB4j</groupId>
    <artifactId>mariaDB4j-maven-plugin</artifactId>
    ...
</plugin>

If you are using the argument "createDatabase" rename it to "databaseName"

JUnit Integration

Using the JUnit feature of Rules a MariaDB4JRule class is available to be used in your tests.

Add it as a @Rule to your test class

public class TestClass {
    @Rule
    public MariaDB4jRule dbRule = new MariaDB4jRule(0); //port 0 means select random available port

    @Test
    public void test() {
        // Do whatever you want with the running DB
    }
}

The MariaDB4jRule provides 2 methods for getting data on the running DB:

  • getURL() - Get the JDBC connection string to the running DB

    @Test
    public void test() {
        Connection conn = DriverManager.getConnection(dbRule.getURL(), "root", "");
    }
    
  • getDBConfiguration() - Get the Configuration object of the running DB, exposing properties such as DB Port, Data directory, Lib Directory and even a reference to the ProcessListener for the DB process.

    public class TestClass {
      @Rule
      public MariaDB4jRule dbRule = new MariaDB4jRule(3307);
    
      @Test
      public void test() {
          assertEquals(3307, dbRule.getDBConfiguration().getPort());
      }
    }
    
    

The MariaDB4jRule class extends the JUnit ExternalResource - which means it starts the DB process before each test method is run, and stops it at the end of that test method.

The MariaDB4jRule(DBConfiguration dbConfiguration, String dbName, String resource) Constructor, allows to initialize your DB with a provided SQL Script (resource = path to script file) to setup needed database, tables and data.

This rule, can also be used as a @ClassRule to avoid DB Process starting every test - just make sure to clean/reset your data in the DB.

Anything else?

Security nota bene: Per default, the MariaDB4j install() creates a new DB with a 'root' user without a password. It also creates a database called "test".

More generally, note that if you are using the provided mariadb database Maven artifacts, then you are pulling platform specific native binaries which will be executed on your system from a remote repository, not just regular Java JARs with classes running in the JVM, through this project. If you are completely security paranoid, this may worry you (or someone else in your organization). If that is the case, note that you could still use only the mariadb4j-core artifact from this project, but use a JAR file containing the binaries which you have created and deployed to your organization's Maven repository yourself. Alternatively, you also use mariadb4j-core to launch and control mariadb binaries installed by other means, e.g. an OS package manager, or perhaps in a (Docker) Container image. This project's sweet spot and main original intended usage scenario is for integration tests, development environments, and possibly simple all-in-one evaluation kind of packages. It's NOT recommended for serious production environments with security awareness and hot fix patch-ability requirements.

MariaDB database JARs, and version upgrades

The original creator and current maintainer of this library (@vorburger) will gladly merge any pull request contributions with updates to the MariaDB native binaries. If you raise a change with new versions, you will be giving back to other users of the community, in exchange for being able to use this free project - that's how open-source works.

Any issues raised in the GitHub bug tracker about requesting new versions of MariaDB native binaries will be tagged with the "helpwanted" label, asking for contributions from YOU or others - ideally from the person raising the issue, but perhaps from someone else, some.. other time, later. (But if you are reading this, YOU should contribute through a Pull Request!)

Note that the Maven number of the core/app/pom artifacts versus the db artifacts, while originally the same, are now intentionally decoupled for this reason. So your new DBs/mariaDB4j-db-(linux/mac/win)(64/32)-VERSION/pom.xml should have its Maven matching the new mariadb binary you are contributing (probably like 10.1.x or so), and not the MariaDB4j launcher (which is like 2.x.y).

In addition to the new directory, you then need to correspondingly increase: 1. the version of the dependency in the mariaDB4j/pom.xml (non-root) & 2. the databaseVersion in the DBConfigurationBuilder class. Please have a look for contributions made by others in the git log if in doubt; e.g. issue 37. Please TEST your pull request on your platform! @vorburger will only only run the build on Linux, not Windows and Mac OS X. As the DBs jars are separated from the main project, one needs to build the DB JAR so it ends it up in your local repo first: cd down the DBs subfolder and do a ./mvnw clean install for the DB you want to build i.e. mariaDB4j-db-mac64-10.1.9/ . After that, up again to the project root repository and ./mvnw clean install should work fine.

So when you contribute new MariaDB native binaries versions, place them in a new directory named mariaDB4j-db-PLATFORM-VERSION under the DBs/ directory - next to the existing ones. This is better than renaming an existing one and replacing files, because (in theory) if someone wanted to they could then easily still depend on earlier released database binary versions just by changing the of the mariaDB4j-db* artifactId in their own project's pom.xml, even with using later version of MariaDB4j Java classes (mariadb4j core & app).

Of course, even if we would replace existing version with new binaries (like it used to originally be done in the project), then the ones already deployed to Maven central would remain there. However it is just much easier to see which version are available, and to locally build JARs for older versions, if all are simply kept in the head main branch (even if not actively re-built anymore, other than the latest version). The size of the git repository will gradually grow through this, and slightly more than if we would replace existing binaries (because git uses delta diffs, for both text and binary files). We just accept that in this project - for clarity & convenience.

FAQ

Q: Is MariaDB4j stable enough for production? I need the data to be safe, and performant. A: Try it out, and if you do find any problem, raise an issue here and let's see if we can fix it. You probably don't risk much in terms of data to be safe and performance - remember MariaDB4j is just a wrapper launching MariaDB (which is a MySQL(R) fork) - so it's as safe and performant as the underlying native DB it uses.

Q: ERROR ch.vorburger.exec.ManagedProcess - mysql: /tmp/MariaDB4j/base/bin/mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory A: This could happen e.g. on Fedora 24 if you have not previous installed any other software package which requires libncurses, and can be fixed by finding the RPM package which provides libncurses.so.5 via sudo dnf provides libncurses.so.5 and then install that via sudo dnf install ncurses-compat-libs. On Ubuntu Focal 20.04, you need to sudo apt update && sudo apt install libncurses5.

Q: /tmp/MariaDB4j/base/bin/mariadbd: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory A: Similar to above, and using e.g. https://pkgs.org/search/?q=libcrypt.so.1 we can see that e.g. sudo dnf install libxcrypt-compat does the trick for Fedora 39.

Q: Is there another project that does something similar to this one? A: Indeed there is, check out wix-embedded-mysql! The world is big enough for both of us, and we cross link. Testcontainers' has something similar which we recommend you use if you can run containers (Docker). Also OpenMRS' liquibase-maven-plugin build on MariaDB4j.

Release?

Remember that mariaDB4j-pom-lite & DBs/mariaDB4j-db-* are now versioned non SNAPSHOT, always fixed; VS the rest that continues to be a 2.2.x-SNAPSHOT (as before). All the steps below except the last one only apply at the root pom.xml (=mariaDB4j-pom) with is mariaDB4j-core, mariaDB4j & mariaDB4j-app <modules>. The mariaDB4j-pom-lite & DBs/mariaDB4j-db-* with their manually maintained fixed <version> however are simply deployed manually with a direct ./mvnw deploy as shown in the last step.

When doing a release, here are a few things to do every time:

  1. update the Maven version numbers in this README

  2. update the dependencies to the latest 3rd-party libraries & Maven plug-in versions available.

  3. Make sure the project builds, without pulling anything which should be part of this build from outside:

    ./mvnw clean package && rm -rf ~/.m2/repository/ch/vorburger && ./mvnw clean package
    
  4. Make to sure that the JavaDoc is clean. Check for both errors and any WARNING (until MJAVADOC-401):

    ./mvnw license:update-file-header
    ./mvnw -Dmaven.test.skip=true package
  5. Finalize CHANGELOG.md Release Notes, incl. set today's date, and update the version numbers in this README.

  6. Preparing & performing the release (this INCLUDES an ./mvnw deploy):

    ./mvnw release:prepare
    ./mvnw release:perform -Pgpg
    ./mvnw release:clean
  7. Deploy to Maven central, only for the mariaDB4j-pom-lite & DBs/mariaDB4j-db projects:

    ./mvnw clean deploy -Pgpg
    

In case of any problems: Discard and go back to fix something and re-release e.g. using EGit via Rebase Interactive on the commit before "prepare release" and skip the two commits made by the maven-release-plugin. Use git push --force to remote, and remove local tag using git tag -d mariaDB4j-2.x.y, and remote tag using 'git push origin :mariaDB4j-2.x.y'. (Alternatively try BEFORE release:clean use './mvnw release:rollback', but that leaves ugly commits.)

Who?

See the CONTRIBUTORS.md file (also included in each built JAR!) for a list of contributors.

Latest/current also on https://github.com/vorburger/MariaDB4j/graphs/contributors:

Contributions, patches, forks more than welcome - hack it, and add your name! ;-)

mariadb4j's People

Contributors

asbachb avatar blanco27 avatar cioan avatar cortiz avatar dassio avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar djazayeri avatar duttonw avatar gaetannandelec avatar glittle1972 avatar jai-deep avatar mdindoffer avatar mrdziuban avatar mseaton avatar osimola avatar paulroemer avatar pre-commit-ci[bot] avatar pwc-glittle avatar robin-xyzt-ai avatar romvoid95 avatar srbala avatar step-security-bot avatar szermatt avatar theknowles avatar thesquaregroot avatar timo-rohwedder avatar vorburger avatar yiftizur 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mariadb4j's Issues

The cleanupOnExit ShutdownHook should not log warnings if directory does not exists

The cleanupOnExit() ShutdownHook logs warnings if the directory, it tries to delete, does not exists anymore. Currently I get warnings in my log, also if the directories doesn't exists.

[warn] c.v.m.DB - cleanupOnExit() ShutdownHook: An error occurred while deleting a directory
java.io.IOException: Unable to delete directory /tmp/MariaDB4j/data/3333.
    at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1541) ~[commons-io-2.4.jar:2.4]
    at ch.vorburger.mariadb4j.DB$1.run(DB.java:336) ~[mariaDB4j-2.1.3.jar:na]
[warn] c.v.m.DB - cleanupOnExit() ShutdownHook: An error occurred while deleting a directory
java.io.IOException: Unable to delete directory /tmp/MariaDB4j/data/3333.
    at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1541) ~[commons-io-2.4.jar:2.4]
    at ch.vorburger.mariadb4j.DB$1.run(DB.java:336) ~[mariaDB4j-2.1.3.jar:na]
[warn] c.v.m.DB - cleanupOnExit() ShutdownHook: An error occurred while deleting a directory
java.io.IOException: Unable to delete file: /tmp/MariaDB4j/base/share/norwegian/errmsg.sys
    at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:2279) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:1653) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1535) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:2270) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:1653) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1535) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:2270) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:1653) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1535) ~[commons-io-2.4.jar:2.4]
    at ch.vorburger.mariadb4j.DB$1.run(DB.java:340) ~[mariaDB4j-2.1.3.jar:na]
[warn] c.v.m.DB - cleanupOnExit() ShutdownHook: An error occurred while deleting a directory
java.io.IOException: Unable to delete directory /tmp/MariaDB4j/base/share.
    at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1541) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:2270) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:1653) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1535) ~[commons-io-2.4.jar:2.4]
    at ch.vorburger.mariadb4j.DB$1.run(DB.java:340) ~[mariaDB4j-2.1.3.jar:na]
[warn] c.v.m.DB - cleanupOnExit() ShutdownHook: An error occurred while deleting a directory
java.io.IOException: Unable to delete file: /tmp/MariaDB4j/base/share/swedish/errmsg.sys
    at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:2279) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:1653) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1535) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:2270) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:1653) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1535) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:2270) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:1653) ~[commons-io-2.4.jar:2.4]
    at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1535) ~[commons-io-2.4.jar:2.4]
    at ch.vorburger.mariadb4j.DB$1.run(DB.java:340) ~[mariaDB4j-2.1.3.jar:na]

Maria4j Managed process does not start correctly if "log-error" is defined in the configuration

As a part of getting a error logs, i added "--log-error=error.log" location as part of my configuration for DB Startup. This is meant to redirect stderr to error.log file. Due to this Parent Process fails with the error "Caused by: ch.vorburger.exec.ManagedProcessException: Database does not seem to have started up correctly? Magic string not seen in 30000ms: mysqld: ready for connections". My guess is that parent process which is looking for string "mysqld: ready for connections" does not find as it looking for it in console, but now this is getting written to error.log.

I am wondering if anybody else has faced this issue and if there is a known workaround.

NoSuchMethodError: org.apache.commons.io.FileUtils.deleteQuietly during Shutdown Hook Deletion Thread for Temporary DB

I have problem with MariaDB4j . When I run it as Junit test , I get this error :

Exception in thread "Shutdown Hook Deletion Thread for Temporary DB C:\Users\petroski\AppData\Local\Temp\MariaDB4j\data\53163" java.lang.NoSuchMethodError: org.apache.commons.io.FileUtils.deleteQuietly(Ljava/io/File;)Z
at ch.vorburger.mariadb4j.DB$1.run(DB.java:369)

Any help with this issue ?
Thank you

VM never quits sometimes, due to hanging non-daemon thread from commons-exec

While investigating and trying to reproduce https://github.com/vorburger/MariaDB4j/issues/10, and (so far..) ONLY time I managed to reproduce https://github.com/vorburger/MariaDB4j/issues/10, I've hit and investigated an issue which isn't directly related to https://github.com/vorburger/MariaDB4j/issues/10 per se - but an equally bad problem in it's own right:

In case of a failure to start the DB, from a main() method, the log shows this, and the JVM got "stuck" and never quit:

669 [main] INFO ch.vorburger.mariadb4j.DB - Starting up the database... 669 [main] INFO ch.vorburger.mariadb4j.DB - mysqld executable: /tmp/MariaDB4j/base/45063/bin/mysqld 669 [main] INFO ch.vorburger.exec.ManagedProcess - Starting Program /tmp/MariaDB4j/base/45063/bin/mysqld --no-defaults --console --skip-grant-tables --max_allowed_packet=64M --basedir=/tmp/MariaDB4j/base/45063 --datadir=/tmp/MariaDB4j/data/45063 --port=45063 --socket=/tmp/MariaDB4j/mysql.45063.sock (in working directory /tmp/MariaDB4j/base/45063) 681 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140723 23:11:32 InnoDB: The InnoDB memory heap is disabled 681 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140723 23:11:32 InnoDB: Mutexes and rw_locks use GCC atomic builtins 681 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140723 23:11:32 InnoDB: Compressed tables use zlib 1.2.3 681 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140723 23:11:32 InnoDB: Using Linux native AIO 686 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140723 23:11:32 InnoDB: Initializing buffer pool, size = 128.0M 691 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140723 23:11:32 InnoDB: Completed initialization of buffer pool 694 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: The first specified data file ./ibdata1 did not exist: 694 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: a new database to be created! 694 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140723 23:11:32 InnoDB: Setting file ./ibdata1 size to 10 MB 694 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: Database physically writes the file full: wait... 731 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140723 23:11:33 InnoDB: Log file ./ib_logfile0 did not exist: new to be created 731 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: Setting log file ./ib_logfile0 size to 5 MB 731 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: Database physically writes the file full: wait... 769 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140723 23:11:33 InnoDB: Log file ./ib_logfile1 did not exist: new to be created 769 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: Setting log file ./ib_logfile1 size to 5 MB 769 [Thread-6] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: Database physically writes the file full: wait... 771 [main] INFO ch.vorburger.exec.ManagedProcess - Thread is now going to wait for ""mysqld: ready for connections."" to appear in Console output of process Program /tmp/MariaDB4j/base/45063/bin/mysqld --no-defaults --console --skip-grant-tables --max_allowed_packet=64M --basedir=/tmp/MariaDB4j/base/45063 --datadir=/tmp/MariaDB4j/data/45063 --port=45063 --socket=/tmp/MariaDB4j/mysql.45063.sock (in working directory /tmp/MariaDB4j/base/45063) for max. 10000ms 10838 [main] WARN ch.vorburger.exec.ManagedProcess - Timed out waiting for ""mysqld: ready for connections."" after 10000ms (returning false) Exception in thread "main" ch.vorburger.exec.ManagedProcessException: Database does not seem to have started up correctly? Magic string not seen: mysqld: ready for connections. at ch.vorburger.mariadb4j.DB.start(DB.java:141) at ch.vorburger.mariadb4j.tests.StartManyTimes.main(StartManyTimes.java:17)

It looked like a Deadlock, but isn't one in the technical sense, here's the relevant jstack:

"Thread-5" daemon prio=10 tid=0x00007ff06c00d000 nid=0x278e runnable [0x00007ff09e56c000] java.lang.Thread.State: RUNNABLE at java.io.FileInputStream.readBytes(Native Method) at java.io.FileInputStream.read(FileInputStream.java:272) at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) at java.io.BufferedInputStream.read1(BufferedInputStream.java:275) at java.io.BufferedInputStream.read(BufferedInputStream.java:334) - locked <0x00000007aef7d110> (a java.lang.UNIXProcess$ProcessPipeInputStream) at java.io.FilterInputStream.read(FilterInputStream.java:107) at org.apache.commons.exec.StreamPumper.run(StreamPumper.java:105) at java.lang.Thread.run(Thread.java:744)

Locked ownable synchronizers: - None

"Thread-4" prio=10 tid=0x00007ff0c4247000 nid=0x278c in Object.wait() [0x00007ff09e6a6000] java.lang.Thread.State: WAITING (on object monitor) at java.lang.Object.wait(Native Method) - waiting on <0x00000007aef7ae78> (a java.lang.UNIXProcess) at java.lang.Object.wait(Object.java:503) at java.lang.UNIXProcess.waitFor(UNIXProcess.java:210) - locked <0x00000007aef7ae78> (a java.lang.UNIXProcess) at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:347) at org.apache.commons.exec.DefaultExecutor.access$200(DefaultExecutor.java:46) at org.apache.commons.exec.DefaultExecutor$1.run(DefaultExecutor.java:188)

Locked ownable synchronizers: - None

"process reaper" daemon prio=10 tid=0x00007ff06c00a000 nid=0x275f runnable [0x00007ff09e5a5000] java.lang.Thread.State: RUNNABLE at java.lang.UNIXProcess.waitForProcessExit(Native Method) at java.lang.UNIXProcess.access$200(UNIXProcess.java:54) at java.lang.UNIXProcess$3.run(UNIXProcess.java:174) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:744)

Locked ownable synchronizers: - <0x00000007aea8c370> (a java.util.concurrent.ThreadPoolExecutor$Worker)

The problem is that Thread-4 is NOT a daemon, so on JVM shutdown it just waits, and waits, and waits...

https://issues.apache.org/jira/browse/EXEC-69 looks like the culprit behind this!!

I'll fix this in MariaDB4j by using the DaemonExecutor workaround attached to EXEC-69 until they fix it upstream in Apache Commons Exec.

Cannot build from source: Unable to retrieve component configurator for plugin configuration

If I try to build the latest version from source then I get a build error:

[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error configuring: org.springframework.boot:spring-boot-maven-plugin. Reason: Unable to retrieve component configurator for plugin configuration
[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error configuring: org.springframework.boot:spring-boot-maven-plugin. Reason: Unable to retrieve component configurator for plugin configuration
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:723)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalWithLifecycle(DefaultLifecycleExecutor.java:556)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkProjectLifecycle(DefaultLifecycleExecutor.java:1205)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.forkLifecycle(DefaultLifecycleExecutor.java:1033)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:643)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeStandaloneGoal(DefaultLifecycleExecutor.java:569)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifecycleExecutor.java:539)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFailures(DefaultLifecycleExecutor.java:387)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(DefaultLifecycleExecutor.java:284)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:180)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:328)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:138)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:362)
    at org.apache.maven.cli.compat.CompatibleMain.main(CompatibleMain.java:60)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
    at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
    at org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
    at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
Caused by: org.apache.maven.plugin.PluginConfigurationException: Error configuring: org.springframework.boot:spring-boot-maven-plugin. Reason: Unable to retrieve component configurator for plugin configuration
    at org.apache.maven.plugin.DefaultPluginManager.populatePluginFields(DefaultPluginManager.java:1368)
    at org.apache.maven.plugin.DefaultPluginManager.getConfiguredMojo(DefaultPluginManager.java:724)
    at org.apache.maven.plugin.DefaultPluginManager.executeMojo(DefaultPluginManager.java:468)
    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoals(DefaultLifecycleExecutor.java:694)
    ... 21 more
Caused by: org.codehaus.plexus.component.repository.exception.ComponentLookupException: Unable to lookup component 'org.codehaus.plexus.component.configurator.ComponentConfigurator', it could not be created
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:335)
    at org.apache.maven.plugin.DefaultPluginManager.populatePluginFields(DefaultPluginManager.java:1351)
    ... 24 more
Caused by: org.codehaus.plexus.component.factory.ComponentInstantiationException: Could not instanciate component: role: 'org.codehaus.plexus.component.configurator.ComponentConfigurator', implementation: 'org.codehaus.plexus.component.configurator.BasicComponentConfigurator', role hint: 'basic'
    at org.codehaus.plexus.component.factory.java.JavaComponentFactory.makeException(JavaComponentFactory.java:77)
    at org.codehaus.plexus.component.factory.java.JavaComponentFactory.newInstance(JavaComponentFactory.java:62)
    at org.codehaus.plexus.DefaultPlexusContainer.createComponentInstance(DefaultPlexusContainer.java:1464)
    at org.codehaus.plexus.component.manager.AbstractComponentManager.createComponentInstance(AbstractComponentManager.java:93)
    at org.codehaus.plexus.component.manager.ClassicSingletonComponentManager.getComponent(ClassicSingletonComponentManager.java:92)
    at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:331)
    ... 25 more
Caused by: java.lang.NoClassDefFoundError: org/codehaus/plexus/classworlds/realm/ClassRealm
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493)
    at java.lang.Class.getConstructor0(Class.java:2803)
    at java.lang.Class.newInstance(Class.java:345)
    at org.codehaus.plexus.component.factory.java.JavaComponentFactory.newInstance(JavaComponentFactory.java:44)
    ... 29 more
Caused by: java.lang.ClassNotFoundException: org.codehaus.plexus.classworlds.realm.ClassRealm
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmClassLoader.java:195)
    at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:255)
    at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClassRealm.java:274)
    at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLoader.java:214)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 34 more

needs happy path example

The docs show db.getConnection() as the correct way to get a connection (go figure) but that method is no longer part of the API; it would be nice to see an end-to-end example of a client project using mariadb4j so users don't have to work out the process every time they need to crank up mysql in a project.

Exception if there are spaces in the data directory path

When using setDataDir() if the path contains spaces then newEmbeddedDB throws an exception. Looks like command line arguments are not being escaped. This could be an attack vector for a malicious user who has control over the database file name.

Exception in thread "main" ch.vorburger.exec.ManagedProcessException: An error occurred while installing the database
    at ch.vorburger.mariadb4j.DB.install(DB.java:117)
    at ch.vorburger.mariadb4j.DB.newEmbeddedDB(DB.java:68)
    ...
Caused by: ch.vorburger.exec.ManagedProcessException: Program [/var/folders/m7/vwmfxlgd5655j5ysw0qbtyg00000gn/T/MariaDB4j/base/bin/mysql_install_db, "--datadir=/Users/john/my database", --basedir=/private/var/folders/m7/vwmfxlgd5655j5ysw0qbtyg00000gn/T/MariaDB4j/base, --no-defaults, --force, --skip-name-resolve] (in working directory /var/folders/m7/vwmfxlgd5655j5ysw0qbtyg00000gn/T/MariaDB4j/base) failed, exitValue=1, last 100 lines of console:
Installing MariaDB/MySQL system tables in './data' ...
/private/var/folders/m7/vwmfxlgd5655j5ysw0qbtyg00000gn/T/MariaDB4j/base/bin/mysqld: Too many arguments (first extra is '"--datadir=/Users/john/my').
150831 16:41:53 [ERROR] Aborting

Concurrency issue in ManagedProcess

Hi.

I noticed the comment "Code review comments most welcome; I'm not 100% sure the thread concurrency time is right; is there a chance a console message may be "missed" here, and we block forever?" in ManagedProcess.java.

There is: If the line is written after you take the copy of console log in getRecentLines but before you initialize the CheckingConsoleOutputStream, it will be missed. A better way to do this would be initializing CheckingConsoleOutputStream first: this way the message line may be read twice but never missed.

Additionally, I think the lines
stdouts.removeOutputStream(checkingConsoleOutputStream);
stderrs.removeOutputStream(checkingConsoleOutputStream);
should be in a finally block so that they will be executed even if Thread.sleep() on the line before is interrupted.

You could also skip the whole sleep and poll loop and use a latch from java.util.concurrent instead.

And finally, CircularFifoBuffer is unsynchronized by default, access to it should be synchronized.

Missing 32bit Linux mariadb (An error occurred while installing the database on Linux but not on windows)

On windows this class is working, but not on linux:

@SpringBootApplication
public class BootMariaScriptApplication implements CommandLineRunner {

public static void main(String[] args) {
    SpringApplication.run(BootMariaScriptApplication.class, args);

}

public void run(String... args) throws Exception {

    DB db = DB.newEmbeddedDB(9306);
    db.start();
    db.createDB("test");
    db.run(sqlscript, "user", "password", "test");
}

22:03:14.728 [main] ERROR o.s.boot.SpringApplication - Application startup failed
java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:675) [spring-boot-1.2.5.RELEASE.jar!/:1.2.5.RELEASE]
at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:690) [spring-boot-1.2.5.RELEASE.jar!/:1.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) [spring-boot-1.2.5.RELEASE.jar!/:1.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957) [spring-boot-1.2.5.RELEASE.jar!/:1.2.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:946) [spring-boot-1.2.5.RELEASE.jar!/:1.2.5.RELEASE]
at be.florentbo.maria.BootMariaScriptApplication.main(BootMariaScriptApplication.java:17) [maria-0.0.1-SNAPSHOT.jar!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_60]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_60]
at java.lang.reflect.Method.invoke(Method.java:497) ~[na:1.8.0_60]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:53) [maria-0.0.1-SNAPSHOT.jar!/:0.0.1-SNAPSHOT]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_60]
Caused by: ch.vorburger.exec.ManagedProcessException: An error occurred while installing the database
at ch.vorburger.mariadb4j.DB.install(DB.java:117) ~[mariaDB4j-2.1.3.jar!/:na]
at ch.vorburger.mariadb4j.DB.newEmbeddedDB(DB.java:68) ~[mariaDB4j-2.1.3.jar!/:na]
at ch.vorburger.mariadb4j.DB.newEmbeddedDB(DB.java:83) ~[mariaDB4j-2.1.3.jar!/:na]
at be.florentbo.maria.BootMariaScriptApplication.run(BootMariaScriptApplication.java:38) [maria-0.0.1-SNAPSHOT.jar!/:0.0.1-SNAPSHOT]
at org.springframework.boot.SpringApplication.runCommandLineRunners(SpringApplication.java:672) [spring-boot-1.2.5.RELEASE.jar!/:1.2.5.RELEASE]
... 11 common frames omitted
Caused by: ch.vorburger.exec.ManagedProcessException: Program /tmp/MariaDB4j/base/bin/mysql_install_db --datadir=/tmp/MariaDB4j/data/9306 --basedir=/tmp/MariaDB4j/base --no-defaults --force --skip-name-resolve (in working directory /tmp/MariaDB4j/base) failed, exitValue=1, last 100 lines of console:
/tmp/MariaDB4j/base/bin/my_print_defaults: 1: /tmp/MariaDB4j/base/bin/my_print_defaults: Syntax error: word unexpected (expecting ")")
Installing MariaDB/MySQL system tables in '/tmp/MariaDB4j/data/9306' ...
/tmp/MariaDB4j/base/bin/mysqld: 1: /tmp/MariaDB4j/base/bin/mysqld: Syntax error: ")" unexpected

Installation of system tables failed! Examine the logs in
/tmp/MariaDB4j/data/9306 for more information.

The problem could be conflicting information in an external
my.cnf files. You can ignore these by doing:

shell> /scripts/mysql_install_db --defaults-file=~/.my.cnf

You can also try to start the mysqld daemon with:

shell> /tmp/MariaDB4j/base/bin/mysqld --skip-grant --general-log &

and use the command line tool /tmp/MariaDB4j/base/bin/mysql
to connect to the mysql database and look at the grant tables:

shell> /tmp/MariaDB4j/base/bin/mysql -u root mysql
mysql> show tables

Try 'mysqld --help' if you have problems with paths. Using
--general-log gives you a log in /tmp/MariaDB4j/data/9306 that may be helpful.

The latest information about mysql_install_db is available at
http://kb.askmonty.org/v/installing-system-tables-mysql_install_db.
MariaDB is hosted on launchpad; You can find the latest source and
email lists at http://launchpad.net/maria

Please check all of the above before mailing us! And remember, if
you do mail us, you should use the /tmp/MariaDB4j/base/scripts/mysqlbug script!
at ch.vorburger.exec.ManagedProcess.checkResult(ManagedProcess.java:279) ~[mariaDB4j-2.1.3.jar!/:na]
at ch.vorburger.exec.ManagedProcess.waitForExitMaxMsWithoutLog(ManagedProcess.java:397) ~[mariaDB4j-2.1.3.jar!/:na]
at ch.vorburger.exec.ManagedProcess.waitForExit(ManagedProcess.java:367) ~[mariaDB4j-2.1.3.jar!/:na]
at ch.vorburger.mariadb4j.DB.install(DB.java:114) ~[mariaDB4j-2.1.3.jar!/:na]
... 15 common frames omitted
Caused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 1 (Exit value: 1)
at org.apache.commons.exec.DefaultExecutor.executeInternal(DefaultExecutor.java:377) ~[commons-exec-1.1.jar!/:1.1]
at org.apache.commons.exec.DefaultExecutor.access$200(DefaultExecutor.java:46) ~[commons-exec-1.1.jar!/:1.1]
at org.apache.commons.exec.DefaultExecutor$1.run(DefaultExecutor.java:188) ~[commons-exec-1.1.jar!/:1.1]
22:03:14.729 [main] INFO o.s.b.c.e.AnnotationConfigEmbeddedWebApplicationContext - Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@134caa4: startup date [Fri Aug 28 22:03:10 CEST 2015]; root of context hierarchy
22:03:14.733 [main] INFO o.s.j.e.a.AnnotationMBeanExporter - Unregistering JMX-exposed beans on shutdown

If baseDir is set libedir has to be repointed too to make use of bundled native libs

Linux native dependency includes two bundled libraries libjemalloc and libeaio.
If we change BaseLib from default these libraries would not be found and in order to fix that LibDir should be set relative to BaseLib. To reproduce - run it on linux with basedir set to something other then SystemUtils.JAVA_IO_TMPDIR + "/MariaDB4j/base"

            configBuilder = DBConfigurationBuilder.newBuilder();
            configBuilder.setBaseDir(dbFolder.getAbsolutePath());
            configBuilder.setLibDir(new File(dbFolder, "libs").getAbsolutePath());  // bundled libs are not found if LibDir is not set to this relative path

It is due to code in DBConfigurationBuilder constructor

        this.baseDir = SystemUtils.JAVA_IO_TMPDIR + "/MariaDB4j/base";
        this.libDir = this.baseDir + "/libs";

If you leave libDir as null on initialization and change implementation of getLibDir I would this it would do the trick

public String getLibDir() {
      if (this.libDir == null)
          return this.baseDir+"/libs"
      else  
         return this.libDir;
}

StartSimulatedForAllPlatformsTest fails with Caused by: java.io.FileNotFoundException: /tmp/MariaDB4j/base/bin/mysqld (Text file busy) on Fedora 24

Run mvn install on MariaDB4j on Fedora 24 causes:

[main] INFO ch.vorburger.mariadb4j.DB - mysqld executable: /tmp/MariaDB4j/base/bin/mysqld.exe
Tests run: 3, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.289 sec <<< FAILURE!
simulatedStartOSX(ch.vorburger.mariadb4j.StartSimulatedForAllPlatformsTest)  Time elapsed: 0.07 sec  <<< ERROR!
java.lang.RuntimeException: Error unpacking embedded DB
    at ch.vorburger.mariadb4j.DB.unpackEmbeddedDb(DB.java:307)
    at ch.vorburger.mariadb4j.StartSimulatedForAllPlatformsTest.checkPlatformStart(StartSimulatedForAllPlatformsTest.java:63)
    at ch.vorburger.mariadb4j.StartSimulatedForAllPlatformsTest.simulatedStartOSX(StartSimulatedForAllPlatformsTest.java:53)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
    at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
Caused by: java.io.FileNotFoundException: /tmp/MariaDB4j/base/bin/mysqld (Text file busy)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at org.apache.commons.io.FileUtils.openOutputStream(FileUtils.java:360)
    at org.apache.commons.io.FileUtils.openOutputStream(FileUtils.java:319)
    at org.apache.commons.io.FileUtils.copyToFile(FileUtils.java:1552)
    at org.apache.commons.io.FileUtils.copyInputStreamToFile(FileUtils.java:1528)
    at org.apache.commons.io.FileUtils.copyURLToFile(FileUtils.java:1478)
    at ch.vorburger.mariadb4j.Util.extractFromClasspathToFile(Util.java:133)
    at ch.vorburger.mariadb4j.DB.unpackEmbeddedDb(DB.java:299)
    ... 31 more

Running normally on Windows 10, Throws Excepiton No suitable driver found in Windows server

  1. mysql-connector-java-5.1.41.jar in the lib.
  2. I don't known what version I should download.
  3. In windows server system: Caused by: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3309/test
    2017-05-05 15:07:16 3712 [ERROR] InnoDB: .\ibdata1 can't be opened in read-write mode
    2017-05-05 15:07:16 3712 [ERROR] InnoDB: The system tablespace must be writable!
    2017-05-05 15:07:16 3712 [ERROR] Plugin 'InnoDB' init function returned error.
    2017-05-05 15:07:16 3712 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
    2017-05-05 15:07:16 3712 [Note] Plugin 'FEEDBACK' is disabled.
    2017-05-05 15:07:16 3712 [ERROR] Unknown/unsupported storage engine: InnoDB
    2017-05-05 15:07:16 3712 [ERROR] Aborting

Password prompt when using dbInstance.source(..)

When using dbInstance.source(..) method with an empty string as password a prompt is shown asking for the password.

db.source("sql/schema.sql", "root", "", "test_db");

I think the method should either validate input and throw an error when an empty string is supplied or treat it the same as a null value.

Spring boot - add autoconfiguration

Hi there,
I am trying to somehow replace the H2 with Mariadb4j for tests in spring boot apps, but i'm having problems with that.
The H2 db startsup very nice out of the box if only available on classpath. It would be a great boost for popularity of this project, if it was prepared for spring boot. A lot of people are complaining about H2 incompatibility.

Stable for production?

Many thanks vorburger, very interesting idea, I am comfortable with MySQL so this solutions suits me.

Is MariaDB4j stable enough for production? I need a similar tool/solution for all-in-one application. There won't much access on the DB, but I need the data to be safe, and I would not mind a decent performance.

Provide "isRunning" method

We try to use this package for running unit tests against a "real" local MySQL database. This also works very good so far.

The only problem is, that it doesn't seem to be able to start and stop the database sequentially.

  • We have an abstract base test, which starts and stops the database
  • All tests inherit from this.
  • Now running multiple tests results in all subsequent test failing as the port is still used.
  • We are using TestNG

It would be nice to have a method, like "isRunning" to check, if the database is still running. Another option would be to have an additonal stopAndWait

NoClassDefFoundError in shutdown hook thread

Hey guys,

first of all thanks for this awesome piece of software. It helps us a lot in our current project.

There is only one problem:

Shutdown Hook Deletion Thread for Temporary DB ../tmp/devdb 2017-01-04 19:49:42 INFO [c.v.m.DB] - cleanupOnExit() ShutdownHook now stopping database
Exec Default Executor 2017-01-04 19:49:44 INFO [c.v.e.ManagedProcess] - Program [/tmp/MariaDB4j/base/bin/mysqld, --no-defaults, --console, --skip-grant-tables, --max_allowed_packet=64M, --basedir=/tmp/MariaDB4j/base, --datadir=/home/vaadin/repos/tmp/devdb, --port=4223, --socket=/tmp/MariaDB4j.4223.sock] (in working directory /tmp/MariaDB4j/base) just exited, with value 0
Shutdown Hook Deletion Thread for Temporary DB ../tmp/devdb 2017-01-04 19:49:44 INFO [c.v.e.ManagedProcess] - Successfully destroyed Program [/tmp/MariaDB4j/base/bin/mysqld, --no-defaults, --console, --skip-grant-tables, --max_allowed_packet=64M, --basedir=/tmp/MariaDB4j/base, --datadir=/home/vaadin/repos/tmp/devdb, --port=4223, --socket=/tmp/MariaDB4j.4223.sock] (in working directory /tmp/MariaDB4j/base)
Shutdown Hook Deletion Thread for Temporary DB ../tmp/devdb 2017-01-04 19:49:44 INFO [c.v.m.DB] - Database stopped.
Shutdown Hook Deletion Thread for Temporary DB ../tmp/devdb 2017-01-04 19:49:44 INFO [c.v.m.DB] - cleanupOnExit() ShutdownHook quietly deleting temporary DB base directory: /tmp/MariaDB4j/base
Exception in thread "Shutdown Hook Deletion Thread for Temporary DB ../tmp/devdb" java.lang.NoClassDefFoundError: org/apache/commons/io/FilenameUtils
        at org.apache.commons.io.FileUtils.isSymlink(FileUtils.java:2924)
        at org.apache.commons.io.FileUtils.deleteDirectory(FileUtils.java:1534)
        at org.apache.commons.io.FileUtils.forceDelete(FileUtils.java:2270)
        at org.apache.commons.io.FileUtils.cleanDirectory(FileUtils.java:1653)
        at org.apache.commons.io.FileUtils.deleteQuietly(FileUtils.java:1566)
        at ch.vorburger.mariadb4j.DB$1.run(DB.java:373)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.io.FilenameUtils
        at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:271)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:247)
        at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:239)
        at org.eclipse.jetty.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:560)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 6 more

That happens if we start our web application via the maven jetty plugin and stop it via Ctrl-C.

It does not hurt us much but it's annoying. I already tried to set the stopWait in the plugin's configuration but that did not help.

Has someone else the same problem?

Cheers,
Paul

Distribution might not be eligible for Apache v2 Licensing

Please look at section 4 of the Apache v2 License, at apache.org. I believe that this binary is not eligible for the Apache v2 license as it redistributes incompatibly licenses binaries, specifically what appears to be a mysql binary. I believe you must include a NOTICE file explaining any of these 3p dependencies with incompatible licenses.

Provide a callback if the DB process crashes

Thanks for the excellent project. I've been having issues where the DB process crashes (too much load, linux OOM killer etc..) and the parent java process has no way of knowing it. I do see a ManagedProcess class, which is private to DB. It would be great if

  • DB exposed a status() API
  • ConfigBuilder accepted an ExecuteResultHandler (like LoggingExecuteResultHandler) and invoked the appropriate methods onProcessComplete or onProcessFailed

Database process hangs sporadically when running inside an other Java application

I use MariaDB4j to test against a MySQL compatible database inside a Play Framework 2 application. If I run the tests from the play console all works as expected. But if I run the tests inside Bamboo or IntelliJ IDEA then the MariaDB process hangs sporadically. I've tried to give more memory or use the newest MariaDB version but this doesn't help.

In IntelliJ IDEA the process exits with exit code 137 and no database process is alive. In Bamboo I must stop the build by hand and then the I must kill the MariaDB process. I run the tests on Linux machines. The processes have no high memory or CPU consumption.

This is the log from a typical MariaDB start:

10:44:37.859 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140514 10:44:37 InnoDB: The InnoDB memory heap is disabled
10:44:37.861 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140514 10:44:37 InnoDB: Mutexes and rw_locks use GCC atomic builtins
10:44:37.861 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140514 10:44:37 InnoDB: Compressed tables use zlib 1.2.3
10:44:37.861 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140514 10:44:37 InnoDB: Using Linux native AIO
10:44:37.861 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140514 10:44:37 InnoDB: Initializing buffer pool, size = 128.0M
10:44:37.864 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140514 10:44:37 InnoDB: Completed initialization of buffer pool
10:44:37.866 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: The first specified data file ./ibdata1 did not exist:
10:44:37.866 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: a new database to be created!
10:44:37.866 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140514 10:44:37  InnoDB: Setting file ./ibdata1 size to 10 MB
10:44:37.866 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: Database physically writes the file full: wait...
10:44:37.868 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140514 10:44:37  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
10:44:37.868 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: Setting log file ./ib_logfile0 size to 5 MB
10:44:37.868 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: Database physically writes the file full: wait...
10:44:37.869 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140514 10:44:37  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
10:44:37.869 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: Setting log file ./ib_logfile1 size to 5 MB
10:44:37.869 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: Database physically writes the file full: wait...
10:44:37.870 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: Doublewrite buffer not found: creating new
10:44:37.875 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: Doublewrite buffer created
10:44:37.879 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: 127 rollback segment(s) active.
10:44:37.880 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: Creating foreign key constraint system tables
10:44:37.882 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: InnoDB: Foreign key constraint system tables created
10:44:37.882 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140514 10:44:37  InnoDB: Waiting for the background threads to start
10:44:38.890 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140514 10:44:38 Percona XtraDB (http://www.percona.com) 5.5.37-MariaDB-34.0 started; log sequence number 0
10:44:38.891 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140514 10:44:38 [Note] Plugin 'FEEDBACK' is disabled.
10:44:38.891 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140514 10:44:38 [Note] Server socket created on IP: '0.0.0.0'.
10:44:38.895 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: 140514 10:44:38 [Note] /tmp/mariaDB4j_8f233556-fd08-47e6-816f-69d3863d8fb0/3333/bin/mysqld: ready for connections.
10:44:38.895 [Thread-5] ERROR ch.vorburger.exec.ManagedProcess - mysqld: Version: '5.5.37-MariaDB'  socket: '/tmp/mariaDB4j_8f233556-fd08-47e6-816f-69d3863d8fb0.mariadb.sock'  port: 3333  MariaDB Server

If the error occurs, then the log stops always with one of the above log entries. It never stops with the same log entry. If the Bamboo build hangs I can connect to the database process and view the database structure. If I kill the database process then the Bamboo build resumes with failed test results. There exists no socket file If the build process hangs but the database is accessible over the port 3333.

Any idea what can solve this issue?

More recent version for mac

How can I get a more recent version of MariaDB for OSX when MariaDB4J starts up? Looks like it's getting 5.5.34. Any way to get something in the 10.1 series?

Error - Access denied for user 'root'@'localhost' (using password: NO)

Hi,

When trying to execute this -
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/myDb", "root", "");

I'm getting error -

Access denied for user 'root'@'localhost' (using password: NO)

Here is my full code

static class MySqlRule extends ExternalResource {
        DB db = null;

        MySqlRule() {
            DBConfigurationBuilder configBuilder = DBConfigurationBuilder.newBuilder();
            configBuilder.setPort(3306); // OR, default: setPort(0); => autom. detect free port
            try {
                db = DB.newEmbeddedDB(configBuilder.build());
                db.start();
                db.source("db/1_create-database.sql");
                db.source("db/2_create-tables.sql", "root", "", "myDb");
                db.source("db/3_seed-data.sql", "root", "", "myDb");
            } catch (ManagedProcessException e) {
                e.printStackTrace();
            }
        }

        @Override
        protected void after() {
            try {
                db.stop();
            } catch (ManagedProcessException e) {
                e.printStackTrace();
            }
        }
    }

Function 'ngram' is not defined

the latest version of MariaDB used does not support fulltext research 'ngram' function.
I have this error Caused by: java.sql.SQLException: Function 'ngram' is not defined when i try to execute this command :CREATE FULLTEXT index LABEL_IDX on ACTOR (label) WITH PARSER ngram;

i used the latest version (2.2.1) of the library.

I think the problem came from MariaDB version.

Can you fix this please?

MariaDB4j in Maven central

Is it possible to deploy MariaDB4j in Maven Central to avoid build the Project everytime we want to use it? Thank you.

ch.vorburger.exec into separate project (with MariaDB4j depending on it)

The meanwhile quite mature and battle tested ch.vorburger.exec helpers (with the tests here) would actually make for a nice new project living separately from MariaDB4j (which would then depend on it, of course) ....

This is a draft documentation for its README: Launching external processes from Java using the raw java.lang.ProcessBuilder API directly can be a little cumbersome. The [Apache Commons Exec library][1] makes it a little easier. The [ch.vorburger.exec library][2] further extends upon Commons Exec to make it truly convenient:

 ManagedProcess proc = new ManagedProcessBuilder("path-to-your-executable-binary")
     .addArgument("arg1")
     .addArgument("arg2")
     .setWorkingDirectory(new File("/tmp"))
     .setDestroyOnShutdown(true)
     .setConsoleBufferMaxLines(7000)
     .build();

proc.start();
int status = proc.waitForExit();
int status = proc.waitForExitMaxMsOrDestroy(3000);
String output = proc.getConsole();

proc.startAndWaitForConsoleMessageMaxMs("started!", 7000);
// use service offered by external process...
proc.destroy();

Please comment / upvote if you would find this interesting & useful?

Don't delete baseDir when it is set to /tmp/

Currently cleanupOnExit deletes the baseDir if it thinks it is a temporary directory, which is determined with isTemporaryDirectory.

isTemoraryDirectory uses directory.startsWith(SystemUtils.JAVA_IO_TMPDIR) to determine whether it is a "temporary directory". I think there might be two different definitions of temporary directory used here though. cleanupOnExit should delete the baseDir if it is a directory which is temporary, as in around only for a short period of time. SystemUtils.JAVA_IO_TMPDIR will tell you if it is a directory for storing temporary files, not if it's a directory that can be removed without issue. The best example of this is '/tmp/', which is what we had it set to.

In fact, cleanupOnExit should not delete any directories it has not created itself.

Access Denied

I have been successfully using MariaDB4j until today. All of a sudden I am getting the following error:

"ERROR 1045 (28000): Access denied for user 'Grant'@'localhost' (using password: NO)"

And this exception a few lines below:

nested exception is ch.vorburger.exec.ManagedProcessException: An error occurred while running a command: create database if not exists 'test'

I'm calling the database as a Spring bean as follows:

	@Bean
	public void testDatabase()throws ManagedProcessException{
		// Start database
		DBConfigurationBuilder configBuilder = DBConfigurationBuilder.newBuilder();
		configBuilder.setPort( 3310 );
		configBuilder.setDataDir("/work/db");
		db = DB.newEmbeddedDB( configBuilder.build() );
		db.start();
		db.createDB( "test" );
	}

I have deleted the database files (/work/db) in case there was corruption but didn't help. I am running this on a Windows machine.

Has anyone seen this before and know what to do to correct?

REQ: support alpine linux

Hi, when running MariaDB4j on a alpine container, we met error:

./mysqld: /usr/lib/libstdc++.so.6: no version information available (required by ./mysqld)

If we must depend gnu libstdc++, could we build a alpine version (based on musl libc) mysqld?

Split out DB binary distribution into separate artifact

I've just noticed that @osimola fork has more interesting stuff than what he's submitted as PRs so far... ;-) In particular commit osimola@b629843 refers to something I did have in mind, but never got to:

@osimola how about instead of just removing the binaries, how about having them in a separate JAR / Maven artifact? So we'd could split up the current one into two JARs - the "code" and the "binaries". Maybe a third pom Maven artifact pulling them both, for simple use as-is-now. Plus probably a little bit of work to make the name of where on the classpath the binaries are (package name, platform dependant & version) - they're currently completely hard-coded.

Shoult if you have time & interest & would like to do that?

Startup fails looking for openssl in specific directory (on Mac OS X)

One of my co-workers got this error when starting our Spring Boot project that uses MariaDB4j. This was on Mac OSX

dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib Referenced from: /private/var/folders/w6/_r897gfx27b3bqj9_zvckvth0000gn/T/MariaDB4j/base/bin/my_print_defaults Reason: image not found

He doesn't use homebrew but uses macports which I think has things installed in different directories. Though it could happen for anyone with libs installed in different directories

The fix was to run
sudo mkdir -p /usr/local/opt/openssl
sudo ln -s /opt/local/lib /usr/local/opt/openssl/.

Not sure if this is a bug worth fixing, or just need to add some documentation tips?

Does this work on Windows?

Trying to use this on Windows. I fail quickly with a ManagedProcessException with cause:

"mysql_install_db was not found, neither in bin/ nor in scripts/ under c:\temp\maria"

I set the base to something simple so it wasn't looking in my program files folder. It appears that the file does exist with an "exe" extension. Is this a bug or is there something else I should be doing?

Do not log info messages as errors

The lib logs a lot of messages as error messages. I think this messages should be more considered as info messages.

[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:12 [Note] /tmp/MariaDB4j/base/bin/mysqld: Normal shutdown
[error] c.v.e.ManagedProcess - mysqld: 
[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:12  InnoDB: Starting shutdown...
[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:14 InnoDB: The InnoDB memory heap is disabled
[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:14 InnoDB: Mutexes and rw_locks use GCC atomic builtins
[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:14 InnoDB: Compressed tables use zlib 1.2.3
[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:14 InnoDB: Using Linux native AIO
[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:14 InnoDB: Initializing buffer pool, size = 128.0M
[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:14 InnoDB: Completed initialization of buffer pool
[error] c.v.e.ManagedProcess - mysqld: InnoDB: The first specified data file ./ibdata1 did not exist:
[error] c.v.e.ManagedProcess - mysqld: InnoDB: a new database to be created!
[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:14  InnoDB: Setting file ./ibdata1 size to 10 MB
[error] c.v.e.ManagedProcess - mysqld: InnoDB: Database physically writes the file full: wait...
[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:14  InnoDB: Log file ./ib_logfile0 did not exist: new to be created
[error] c.v.e.ManagedProcess - mysqld: InnoDB: Setting log file ./ib_logfile0 size to 5 MB
[error] c.v.e.ManagedProcess - mysqld: InnoDB: Database physically writes the file full: wait...
[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:14  InnoDB: Log file ./ib_logfile1 did not exist: new to be created
[error] c.v.e.ManagedProcess - mysqld: InnoDB: Setting log file ./ib_logfile1 size to 5 MB
[error] c.v.e.ManagedProcess - mysqld: InnoDB: Database physically writes the file full: wait...
[error] c.v.e.ManagedProcess - mysqld: InnoDB: Doublewrite buffer not found: creating new
[error] c.v.e.ManagedProcess - mysqld: InnoDB: Doublewrite buffer created
[error] c.v.e.ManagedProcess - mysqld: InnoDB: 127 rollback segment(s) active.
[error] c.v.e.ManagedProcess - mysqld: InnoDB: Creating foreign key constraint system tables
[error] c.v.e.ManagedProcess - mysqld: InnoDB: Foreign key constraint system tables created
[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:14  InnoDB: Waiting for the background threads to start
[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:15 Percona XtraDB (http://www.percona.com) 5.5.33a-MariaDB-31.1 started; log sequence number 0
[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:15 [Note] Plugin 'FEEDBACK' is disabled.
[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:15 [Note] Server socket created on IP: '0.0.0.0'.
[error] c.v.e.ManagedProcess - mysqld: 150730  9:41:15 [Note] /tmp/MariaDB4j/base/bin/mysqld: ready for connections.
[error] c.v.e.ManagedProcess - mysqld: Version: '5.5.33a-MariaDB'  socket: '/tmp/MariaDB4j.3333.sock'  port: 3333  MariaDB Server

Enable parallel test execution

First of all thank you for providing mariaDB4j. It works very well and it is a very good solution for my needs.

I have a bunch of users working on the same server. Let's say user1 test's his DAO against mariaDB4j. A folder named 'mariaDB' will be created in the temp folder of the server. After the tests are done, user2 wants to test his database tests too, but errors are occurring which are due to the directory which has already been created by user 1.

Is there a way to allow parallel execution of tests against the mariaDB database?

Problem with windows user

Hi,

I'm having a problem because my windows user is "Daniel SMITH" and the ConfigurationBuilder don't recognize it:

ERROR:
ch.vorburger.exec.ManagedProcessException: Asked to wait for "mysqld.exe: ready for connections." from Program [C:\Users\DANIEL1\AppData\Local\Temp\MariaDB4j\base\bin\mysqld.exe, --no-defaults, --console, --skip-grant-tables, --max_allowed_packet=64M, --basedir="C:\Users\Daniel SMITH\AppData\Local\Temp\MariaDB4j\base", --datadir="C:\Users\Daniel SMITH\AppData\Local\Temp\MariaDB4j\data\3307", --port=3307] (in working directory C:\Users\DANIEL1\AppData\Local\Temp\MariaDB4j\base), but it already exited! (without that message in console), last 100 lines of console:
...........
C:\Users\DANIEL~1\AppData\Local\Temp\MariaDB4j\base\bin\mysqld.exe: Too many arguments (first extra is 'SMITH\AppData\Local\Temp\MariaDB4j\base').
170119 16:56:13 [ERROR] Aborting

If I configure the ConfigurationBuilder with baseDir, example configurationBuilder.setBaseDir("C:/mariadb");

I have this ERROR:

ch.vorburger.exec.ManagedProcessException: Program [C:\mariadb\bin\mysqld.exe, --no-defaults, --console, --skip-grant-tables, --max_allowed_packet=64M, --basedir=C:\mariadb, --datadir=C:\mariadb, --port=3307] (in working directory C:\mariadb) failed, exitValue=1, last 100 lines of console:
............
170119 18:07:41 [Note] InnoDB: Completed initialization of buffer pool
170119 18:07:41 [ERROR] InnoDB: .\ibdata1 can't be opened in read-write mode
170119 18:07:41 [ERROR] InnoDB: The system tablespace must be writable!
170119 18:07:41 [ERROR] Plugin 'InnoDB' init function returned error.
170119 18:07:41 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.

Thanks

mvn release:prepare fails to push new tag to remote GitHub because it's using the wrong developerConnection SCM

Doing a mvn release:prepare now suddenly fails with this error:

    [INFO] --- spring-boot-maven-plugin:1.3.6.RELEASE:repackage (default) @ mariaDB4j-app ---
    [INFO] ------------------------------------------------------------------------
    [INFO] Reactor Summary:
    [INFO] 
    [INFO] mariaDB4j-pom ...................................... SUCCESS [  3.141 s]
    [INFO] mariaDB4j-core ..................................... SUCCESS [ 13.064 s]
    [INFO] mariaDB4j (all-in-one artifact) .................... SUCCESS [02:04 min]
    [INFO] mariaDB4j-app ...................................... SUCCESS [ 20.745 s]
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 02:42 min
    [INFO] Finished at: 2016-07-25T02:14:10+02:00
    [INFO] Final Memory: 53M/925M
    [INFO] ------------------------------------------------------------------------
[INFO] Checking in modified POMs...
[INFO] Executing: /bin/sh -c cd /home/vorburger/dev/MariaDB4j/git/MariaDB4j && git add -- pom.xml mariaDB4j-core/pom.xml mariaDB4j/pom.xml mariaDB4j-app/pom.xml
[INFO] Working directory: /home/vorburger/dev/MariaDB4j/git/MariaDB4j
[INFO] Executing: /bin/sh -c cd /home/vorburger/dev/MariaDB4j/git/MariaDB4j && git rev-parse --show-toplevel
[INFO] Working directory: /home/vorburger/dev/MariaDB4j/git/MariaDB4j
[INFO] Executing: /bin/sh -c cd /home/vorburger/dev/MariaDB4j/git/MariaDB4j && git status --porcelain .
[INFO] Working directory: /home/vorburger/dev/MariaDB4j/git/MariaDB4j
[WARNING] Ignoring unrecognized line: ?? mariaDB4j-app/pom.xml.releaseBackup
[WARNING] Ignoring unrecognized line: ?? mariaDB4j-core/pom.xml.releaseBackup
[WARNING] Ignoring unrecognized line: ?? mariaDB4j/pom.xml.releaseBackup
[WARNING] Ignoring unrecognized line: ?? pom.xml.releaseBackup
[WARNING] Ignoring unrecognized line: ?? release.properties
[INFO] Executing: /bin/sh -c cd /home/vorburger/dev/MariaDB4j/git/MariaDB4j && git commit --verbose -F /tmp/maven-scm-241871119.commit pom.xml mariaDB4j-core/pom.xml mariaDB4j/pom.xml mariaDB4j-app/pom.xml
[INFO] Working directory: /home/vorburger/dev/MariaDB4j/git/MariaDB4j
[INFO] Executing: /bin/sh -c cd /home/vorburger/dev/MariaDB4j/git/MariaDB4j && git symbolic-ref HEAD
[INFO] Working directory: /home/vorburger/dev/MariaDB4j/git/MariaDB4j
[INFO] Executing: /bin/sh -c cd /home/vorburger/dev/MariaDB4j/git/MariaDB4j && git push [email protected]:vorburger/MariaDB4j.git/mariaDB4j-pom refs/heads/master:refs/heads/master
[INFO] Working directory: /home/vorburger/dev/MariaDB4j/git/MariaDB4j
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO] 
[INFO] mariaDB4j-pom ...................................... FAILURE [02:54 min]
[INFO] mariaDB4j-core ..................................... SKIPPED
[INFO] mariaDB4j (all-in-one artifact) .................... SKIPPED
[INFO] mariaDB4j-app ...................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 02:55 min
[INFO] Finished at: 2016-07-25T02:14:12+02:00
[INFO] Final Memory: 19M/287M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:2.5.3:prepare (default-cli) on project mariaDB4j-pom: Unable to commit files
[ERROR] Provider message:
[ERROR] The git-push command failed.
[ERROR] Command output:
[ERROR] fatal: remote error:
[ERROR] vorburger/MariaDB4j.git/mariaDB4j-pom is not a valid repository name
[ERROR] Email [email protected] for help

We can see that the remote URL ([email protected]:vorburger/MariaDB4j.git/mariaDB4j-pom) is wrong - it should be without the artifactId (just [email protected]:vorburger/MariaDB4j.git), of course.

Given that there is a 2.5.0 tag from the previous release I did on May 5th, I'm struggling to understand what could have broken this. Unless I had done that tag manually because it already wasn't working then? I forgot.

I'd guess vorburger@97344bf broke it, but I did that JUST before the 2.5.0, so ... I don't think so. Anyway that weird 3.0-r1585899 is gone with the wind I think, and not coming back (no idea where it came from!), so that's moot.

Wonderinf if f8e6b64 which moved the into a non-SNAPSHOT pom.xml could have caused it to get confused like that? I'll try to move it, and we'll see.

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.