Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 3 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
View
3 .settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+#Mon Mar 12 23:31:56 CET 2012
+eclipse.preferences.version=1
+encoding/<project>=ISO-8859-1
View
59 LEGAL.txt
@@ -1,27 +1,32 @@
-IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL
-AKA: "This section is not a substitute for professional legal advice. It is intended to
-provide general guidance to developers, but it was not prepared by an attorney nor is
-it in any way legal advice."
------------------------------------------------------------------------------------------------
-
-This library is dual licensed under the Apache License 2.0 & the Eclipse Public License v1.0.
-The ASL and EPL licenses, instead of GPL, have been chosen so that non-GPL Java applications
-can use this.
-
-As such, note that this library must never "combine" with GPL licensed code.
-The pure "distribution" of the GPL licensed MariaDB binaries with this JAR is OK, as
-this Java library never "links" to those binaries, but merely "launches"
-them a separate OS process (non shared address space).
-
-Here is a link to MariaDB's GPL license:
-http://kb.askmonty.org/en/mariadb-license
-
-Here is a link allowing you to download MariaDB's source code:
-http://kb.askmonty.org/en/getting-the-mariadb-source-code
-
-Note that you have to figure out yourself whether you can use the MySQL� JDBC driver (Connector/J) from Oracle in your application.
-The MySQL� JDBC driver (Connector/J) is GPL licensed, but due to the MySQL FLOSS License Exception,
-it "permits linking with other components that are licensed under OSI-approved open source licenses".
-
------------------------------------------------------------------------------------------------
-IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL
+IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL
+AKA: "This section is not a substitute for professional legal advice. It is intended to
+provide general guidance to developers, but it was not prepared by an attorney nor is
+it in any way legal advice."
+-----------------------------------------------------------------------------------------------
+
+This library is dual licensed under the Apache License 2.0 & the Eclipse Public License v1.0.
+The ASL and EPL licenses, instead of GPL, have been chosen so that non-GPL Java applications
+can use this.
+
+As such, note that this library must never "combine" with GPL licensed code.
+The pure "distribution" of the GPL licensed MariaDB binaries with this JAR is OK, as
+this Java library never "links" to those binaries, but merely "launches"
+them a separate OS process (non shared address space).
+
+Here is a link to MariaDB's GPL license:
+http://kb.askmonty.org/en/mariadb-license
+
+Here is a link allowing you to download MariaDB's source code:
+http://kb.askmonty.org/en/getting-the-mariadb-source-code
+
+Note that you have to figure out yourself whether you can use the MySQL� JDBC driver (Connector/J) from Oracle in your application.
+The MySQL� JDBC driver (Connector/J) is GPL licensed, but due to the MySQL FLOSS License Exception,
+it "permits linking with other components that are licensed under OSI-approved open source licenses".
+
+http://kb.askmonty.org/en/mariadb-faq-is-there-any-java-connector-for-mariadb-than-the-one-from-mysql
+says that For most cases there is no license requirement for using the JDBC connector as the GPL for
+the connector will not affect your application because you have the JDBC manager in between.
+See the Licensing FAQ <http://kb.askmonty.org/en/licensing-faq> for details.
+
+-----------------------------------------------------------------------------------------------
+IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL IANAL
View
53 TODO.txt
@@ -1,28 +1,25 @@
-
-mysql_install_db --datadir totodata [--basedir=/usr/local/mysql]
-
-mysqld --datadir .\totodata
-
-mysql -u root
-
-mysqlcheck --auto-repair --all-databases -u root
-
-
-
-BEFORE RELEASING v1
-
-- contact ABC & XYZ if any thoughts or advise?
-
-- Apache License header everywhere
-
-- LICENSE.txt & README must be included in JAR
-
-- pom.xml must have all required elements so that this doesn't complain:
- mvn clean verify source:jar javadoc:jar repository:bundle-create
-
-
-LATER, MAY BE
-
-- could split project into multi-module, e.g. exec4j, mariaDB4j-core, mariaDB4j-db-win, mariaDB4j-db-linux (and still have a mariaDB4j:mariaDB4j which aggregates them all like initial version)
-
-- propose ch.vorburger.exec as "handy utilities" to commons-exec?
+BEFORE RELEASING v1
+
+- TODOs
+
+- How to do 32 vs 64 bit?! How to detect? How to choose? (Is it even needed? Prio?)
+
+- my.cnf files
+
+- mysqlcheck --auto-repair --all-databases -u root
+
+- contact ABC & XYZ if any thoughts or advise?
+
+- Apache License header everywhere
+
+- LICENSE.txt & README must be included in JAR
+
+- pom.xml must have all required elements so that this doesn't complain:
+ mvn clean verify source:jar javadoc:jar repository:bundle-create
+
+
+LATER, MAY BE
+
+- could split project into multi-module, e.g. exec4j, mariaDB4j-core, mariaDB4j-db-win, mariaDB4j-db-linux (and still have a mariaDB4j:mariaDB4j which aggregates them all like initial version)
+
+- propose ch.vorburger.exec as "handy utilities" to commons-exec?
View
17 src/main/java/ch/vorburger/exec/ManagedProcess.java
@@ -122,6 +122,12 @@ public void start() throws IOException, IllegalStateException {
executor.setProcessDestroyer(shutdownHookProcessDestroyer);
}
+ if (commandLine.isFile()) {
+ chmodX(new File(commandLine.getExecutable()));
+ } else {
+ logger.warn(commandLine.getExecutable() + " is not a java.io.File, so it won't be made executable (which will be a problem on *NIX...)");
+ }
+
executor.execute(commandLine, resultHandler);
isAlive = true;
@@ -145,6 +151,17 @@ public void start() throws IOException, IllegalStateException {
checkResult();
}
+ protected void chmodX(File executableFile) {
+ if (!executableFile.canExecute()) {
+ boolean succeeded = executableFile.setExecutable(true);
+ if (succeeded) {
+ logger.info("chmod +x " + executableFile.toString() + " (using java.io.File.setExecutable)");
+ } else {
+ logger.error("Failed to do chmod +x " + executableFile.toString() + " using java.io.File.setExecutable, which will be a problem on *NIX...");
+ }
+ }
+ }
+
protected void checkResult() throws ExecuteException {
if (resultHandler.hasResult()) {
// We already terminated (or never started)
View
14 src/main/java/ch/vorburger/mariadb4j/DB.java
@@ -30,9 +30,9 @@
import ch.vorburger.exec.ManagedProcessBuilder;
/**
- * MariaDB (or MySQL®) Controller.
+ * MariaDB (or MySQL) Controller.
*
- * You need to give the path to a previously unpacked MariaDB (or MySQL®), as
+ * You need to give the path to a previously unpacked MariaDB (or MySQL), as
* well as your data directory, here.
*
* @see EmbeddedDB
@@ -65,8 +65,14 @@ public DB(File basedir, File datadir) throws IOException {
checkNonNull(datadir, "datadir");
this.datadir = datadir;
- mysqld = new ManagedProcessBuilder(cmd("mysqld")).addArgument("--datadir").addArgument(datadir).build();
- mysql_install = new ManagedProcessBuilder(cmd("mysql_install_db")).addArgument("--datadir").addArgument(datadir).build();
+ mysqld = addCommonArgs(new ManagedProcessBuilder(cmd("mysqld"))).build();
+ mysql_install = addCommonArgs(new ManagedProcessBuilder(cmd("mysql_install_db"))).directory(basedir).build();
+ }
+
+ protected ManagedProcessBuilder addCommonArgs(ManagedProcessBuilder builder) throws IOException {
+ builder.addArgument("--datadir").addArgument(datadir);
+ builder.addArgument("--basedir").addArgument(basedir);
+ return builder;
}
public DB(String basedir, String datadir) throws IOException {
View
19 src/main/java/ch/vorburger/mariadb4j/DBFactory.java
@@ -62,7 +62,7 @@ public static DB newEmbeddedDB(File datadir) throws UnknownPlatformException, IO
* This is useful e.g. for integration tests.
*/
public static DB newEmbeddedTemporaryDB() throws UnknownPlatformException, IOException {
- final File datadir = new File(FileUtils.getTempDirectory(), "mariaDB4j/tempDBs/" + System.nanoTime());
+ final File datadir = new File(getTempDirectory(), "mariaDB4j/tempDBs/" + System.nanoTime());
final DB db = newEmbeddedDB(datadir);
db.setAutoInstallDB(true);
@@ -99,7 +99,7 @@ protected static File unpackEmbeddedDB() throws IOException, UnknownPlatformExce
}
protected static File unpackEmbeddedDB(String nameAndVersion) throws IOException, UnknownPlatformException {
- return unpackEmbeddedDB(nameAndVersion, new File(FileUtils.getTempDirectory(), "mariaDB4j/base"));
+ return unpackEmbeddedDB(nameAndVersion, getTemporaryBaseDir());
}
protected static File unpackEmbeddedDB(String nameAndVersion, File rootDir) throws IOException {
@@ -107,7 +107,22 @@ protected static File unpackEmbeddedDB(String nameAndVersion, File rootDir) thro
String packagePath = DB.class.getPackage().getName().replace('.', '/') + '/' + suffix;
File dir = new File(rootDir, suffix);
ClasspathUnpacker.extract(packagePath, dir);
+ chmodXs(dir);
return dir;
}
+ protected static void chmodXs(File dir) {
+ // TODO Implement chmod +x, with logging, à la what I have done in ManagedProcess...
+
+ }
+
+ protected static File getTempDirectory() {
+ return FileUtils.getTempDirectory();
+ }
+
+
+ protected static File getTemporaryBaseDir() {
+ return new File(getTempDirectory(), "mariaDB4j/base");
+ }
+
}
View
7 src/test/java/ch/vorburger/mariadb4j/MariaDB4jSampleTutorialTest.java
@@ -24,6 +24,8 @@
import java.sql.DriverManager;
import java.sql.Statement;
+import org.apache.commons.io.FileUtils;
+import org.junit.BeforeClass;
import org.junit.Test;
/**
@@ -35,6 +37,11 @@
*/
public class MariaDB4jSampleTutorialTest {
+ @BeforeClass
+ public static void beforeClass() throws IOException {
+ FileUtils.deleteDirectory(DBFactory.getTemporaryBaseDir());
+ }
+
@Test(expected=IOException.class)
public void testBadFixedPathMariaDB4j() throws Exception {
// No DB in bin/ here, should fail:

No commit comments for this range

Something went wrong with that request. Please try again.