I am looking for embedded MySQL for Java. I looked at answers for "Create embedded mysql database"
and found libmysqld but it is for C++, as MySQL itself of course is written in C/C++.
Could not find better for MySQL per se.
Recalling about MariaDB, I quickly found https://github.com/vorburger/MariaDB4j but I am still raising question. Is there better solution for standalone app (that is only one local connection, we never can access that db)
UPDATE: There is no much I know. We should have embed all into one Java executable, but for the developers it should be the same as the MySQL on central server where mySQL native SQL calls are used. So having the same DB for main server and standalone app is supposed to save time developing against different DBs.
Related
I am currently working on a university project to set up a database and a java GUI for the company I work at.
My idea was to use JavaDB (JDK-integrated Derby) or MySQL as database engine and connect to a Java application that I code using DBMC.
Ideally, both the Database and GUI Java Application would simply be saved on the company's network drive in the same folder, without the need of a permanently running an SQL server or something like that.
So when a user started up the Java application, the database (server) would start up too and close when the Java Application is closed.
I was messing around with Derby Embedded, but found that it was fairly impractical, lacking a useful gui administration tool like MySQL or multi-user access (not the first priority) and accessing it via SQuirreL didn't succeed very well either.
Do you know a better solution to this?
Would it be possible to do this with MySQL for example?
I hope, I explained everything okay.
I have never used Derby but I've seen that it can be embeded in my java application. If I decide to make my application by derby is there a way to place my database files in my specified application directory so I expect it to be portable and when I copy the database files to another application which can use them they will be copied safely?(I think that it was impossible for mysql thus it has a global configuration)
By the way I'd like to know if Derby has a client/server access system or it can be used like SQLite. My database is so easy and I need no client/server structure. Do client/server structures reduce the performance when they are compared with SQLite structure?
Derby is an open source relational database implemented entirely in Java based on Java, Sql, JDBC standards.
when I copy the database files to another application which can use
them they will be copied safely?
Yes it is portable and can be copied safely
I'd like to know if Derby has a client/server access system or it can
be used like SQLite
Derby supports the more familiar client/server mode with the Derby Network Client JDBC driver and Derby Network Server. check this link
for a full tutorial on how to use Derby with eclipse I'd suggest you to read this tutorial written by IBM
Good Luck
I am in a situation where I am being asked to make a single WAR file that runs Wordpress. Using Quercus, Tomcat and httpd+mod_rewrite I was able to make a WAR file containing everything except the database, which I ran externally. However, I'm not sure how I might go about removing the dependency upon an external database (and, frankly, this whole endeavor seems like a bad idea to me).
This article describes how Wordpress has been successfully deployed on the Google App Engine and hence without needing MySQL, but this was done using JPA.
Instead of embedding a MySQL instance, if I could use an external MSSQL database connection instead that would be fine too. (This is an old post, but it seems to suggest that real MySQL is the only supported database for Wordpress.) Is the most viable option to attempt to replace each MySQL call in the Wordpress source code to a MSSQL call? Is there some kind of compatibility/translation layer that I could use instead? (I saw this question, but the solution will not work in my case.)
UPDATE: I came across MySQL-JE, but it looks out of date and not quite complete enough (not sure how I would tell Quercus/PHP to communicate with it). Has anyone used it? If so, do you think it would help solve this problem?
Embedded Database
According to this chart, MySQL is not built for embedded use.
I can point you to two pure Java database engines for embedding in a Java app. Both are open-source, free of cost, and under active development. Both have a good pedigree with a long line of database development history behind them.
H2
Derby
WordPress Requires MySQL
According to this WordPress Requirements page, specifically MySQL is required. That's annoying. The main point of SQL is to avoid database-vendor lock-in.
I started ussing JPA not long ago and I think it is great because of its annotations that make programming so simple. But I still have a lot few doubts that slow me down a bit (most of the times regarding to configuration issues):
I would like to understand the difference between the derby DB that comes in the OEPE(Oracle Enterprise Pack for Eclipse), I was using this for my learning, and the popular MySQL DB(www.mysql.com). What confuses me is what is the difference with an embedded DB an a non embedded. What is better, what do you recommend?
The second doubt is regarding to some configuration issue I can't fix with my derby DB(not embedded mode) I already made a question, but I could not fix it. The problem is that when I try to access some of the tables of my DB(The tables exist in the database, they were created by the JPA feature generate Tables from entities), I get SQLSyntaxErrorException saying that the tables don't exist. I know that is impossible because that same query manually inserted in eclipses scrapbook works correctly. I know this have something to do some configuration issue, but I don't know what is it.
I'll be really happy if someone with a bit more experience with JPA could give me a hand.
The tools I use for my programming are eclipse + OEPE, Java EE 6 and GlassfishV3.0
This is the link to my other question where I explain the issue in more detail:
SQLSyntaxErrorException: Table/View 'BUYER' does not exist. What is missing?
Thanks in advance.
Regarding question 1:
Derby/JavaDB has two operation modes (quoted form JavaDB documentation):
Embedded
Refers to Derby being started by a
simple single-user Java application.
With this option Derby runs in the
same Java virtual machine (JVM) as the
application. Derby can be almost
invisible to the end user because it
is started and stopped by the
application and often requires no
administration. The Derby
documentation often refers to this as
the embedded configuration or embedded
mode.
Server (or Server-based)
Refers to Derby being started by an
application that provides multi-user
connectivity to Derby databases across
a network. With this option Derby runs
in the Java virtual machine (JVM) that
hosts the Server. Applications connect
to the Server from different JVMs to
access the database. The Derby Network
Server is part of the Derby software
distribution and provides this type of
framework for Derby. Derby also works
well with other, independently
developed Server applications. The
Derby documentation often refers to
this as the Network Server
configuration or client/server
configuration.
From my experience, the main differences of both modes are that in embedded mode, the database is part of your application and only one user can connect to the database.
In server mode, the database is not part of your application, runs in a different JVM or on another machine and operates in multi-user/multi-connection mode.
Regarding comparison of JavaDB and MySQL, I think it depends on your application and functional requirements. A quick google search revealed this comparison of relational db systems (Derby can be found there under letter "A" for Apache Derby).
i am not clear about steps/configuration details about how i can embed mysql in a Java desktop application so that it(application) can be installed on any machine through a single executable file and doing so sets up database and also provides an exe to run the app.Till now i have built my app using netbeans and i have used mysql to set up database.plz guide me further.
MySQL isn't an embedded database - the only JAR related to it is the JDBC driver. It requires a installation process, which might be able to be scripted via Java, but the process will definitely function outside of the Java application you intend it to support. Meaning, you can turn off your Java application but the MySQL service/daemon will still be running.
Only the libmysqld is embeddable.
There are embedded databases - SQLite, Firebird - and embedded databases made in Java - HSQL, Derby/(can't remember what it was called before). I believe SQL Server Compact Edition is embeddable, while SQL Server Express/MSDE is not. I don't know if Oracle has an embeddable version....
I would strongly recommend H2. It is a very fast embedded database written in Java and I've found it easier to use than some of the others mentioned such as HSQL.
Edit:
On the H2 website, you can see a speed comparison of H2 vs Derby, HSQL, MySql, etc...
Here's information on how to backup the database.
While theoritcaly possable it would not be easy. The standard MySql distributions assume you want to set up a general purpose database server with separate from the client applications cominicating via odbc etc.
You may be better looking at the "pure java" options like HSQL or JavaDB which are designed to be embedded in a java application, and need little or no "setup".
Another possibility is Sqlite which only needs a single binary plus the sqljbbc jar file. This is again designed from scratch to be embedded inside an application and requires zero admin apart from allocating a file for the database.
Take a look at http://dev.mysql.com/doc/refman/5.0/en/connector-mxj.html. I do not remember the exact details but I was able to embed MySQL db in desktop application without user needing to install it separately.
The key class is com.mysql.management.MysqldResource.
Here is the example, http://dev.mysql.com/doc/refman/5.0/en/connector-mxj-configuration-java-object.html
The mysql-connector-mxj-gpl-db-files.jar file contains MySQL installation files for all the platforms. If you know which is your target platform, you can strip other platform versions from jar, to reduce download size for end user.
If you want an embedded database with java, then use one written in Java designed to be embedded. I know Apache Derby Can be embedded and apparently H2 too.
How big amount of data dó you need the database to handle?