Embeddable database better than SQLite for java - java

I am creating a web application that is accessing a SQLite database in the server. I also have "clients" that updates this same database. As we know SQLite locks the entire database during INSERTs which are done by the clients and the web application is also trying to make some UPDATEs at the same time. So my problem now is about concurrency in database access. I would like to use an embeddable database like SQLite. Any suggestions.

H2 database the new thing from the creator of Hypersonic SQL: H2 stands for Hypersonic 2, however H2 does not share code with Hypersonic SQL or HSQLDB. H2 is built from scratch.

HSQLDB

If you value convenience over raw performance the database bundled with Java 6, JavaDB/Derby, may work well for you. It offers row-level locking and has it enabled by default.

You've got to the point where I would be switching to using a separate database server. The SQLite wiki has a page on when to use SQLite and when not; highly concurrent writes are one of the times when you're beyond its architecture (which deliberately doesn't handle this case well so it can do better at others).
PostgreSQL and MySQL are probably your first ports of call.

Try Oracle's Berkeley DB.

Thought about MySQL? We're using it in our application an it works great.

Related

Embedded DBs compatible with SQL Server Data

Working on a JAX-RS application which uses Microsoft-SQL-Server as a Database.
It does not use any ORM frameworks, just plain old JDBC.
Most of the application's operations involve store and retrieve data as XML into DB tables.
I have a use case where I have to run this application offline. So there wont be any connection available to DB SQL-Server.
Whilst looking into my options thought I would embed the DB and ship with the application EAR.
Looking into options I learned that, SQL-Server-Compact does not have a proper JDBC driver.
Is there any other In-Memory DB that could serve my purpose?
I want avoid any code changes like: changing the SQL queries (written specifically for Microsoft-SQL-Server).
Is there any solution which I can use and ship my application just by changing the DataSource to embedded DB?
note: I could not find any useful post on stackoverflow for this query, If it's already been discussed. Please point me to the post and I will delete this duplicate question.

Spring boot reactive (Webflux) with MySql

I would develop an Spring boot application compliant with new feature Webflux.
Does an driver JDBC for Mysql exist?
I found just driver for some NoSql DB (for ex. MongoDB).
Could you help me?
Thanks, regards.
UPDATE:
On official site of R2DBC project there is the drivers list: https://r2dbc.io/
Actually there isn't any reactive support for relational database. But not for long time since the Spring Data team is working on R2DBC, which will provide the ability to access data reactively from a relational database. Stay tuned here: https://github.com/r2dbc
EDIT
The first release is out, see here for more details: https://github.com/r2dbc/r2dbc-postgresql/tags
An asynchronous driver for MySQL exists and it's called jasync-sql:
https://github.com/jasync-sql/jasync-sql
No there is no reactive driver for MySQl. There is one for Postgres:
https://github.com/r2dbc/r2dbc-client
it uses all the reactive bits from project rector (collections are return as flux). Of Course you are back to working with prepared statements. And pulling data directly from the Serch reasult.
And the one for the oracle DB:
https://github.com/oracle/oracle-db-examples/tree/master/java/AoJ
But it uses a blocking JDBC calls and only hides the problem of behind thread pool. However it represent the current effort at Oracle to attack the problem. And it is not a trivial thing as there is a certain philosophy when working with relational databases of consistent state. That is why your query result is return all at once unlike mongodb that can return result as it comes in.
Because of that any ORM (hibernate, eclipselink) tooling is nowhere.
I think for production code we are stuck with blocking calls for now.

Java, connect to mysql file without server

I wonder if it's possible to use the database file from mysql, without having a server running. Just copying the db file and place it somewhere, then use "jdbc:mysql://localhost:3306/table";
and change it to something like "jdbc:mysql://C:/Users/me/Desktop/table";
Will this work or is there a better way?
This is not possible with Mysql. Sqlite is a Serverless database designed for this purpose.
You're probably looking for an embedded database, i.e. as you say a library that is able to access a database on a file without a server.
MySQL has an embeddable version: http://www.mysql.com/oem/
You might want to check also H2: http://www.h2database.com/
Or Apache Derby: http://db.apache.org/derby/
Or HSQLDB: http://hsqldb.org/
Short answer: no.
Long answer: You'd have to basically recreate the MySQL daemon in Java. In particular, JDBC would have to know the structures inside of the file. The files are quite complicated, and this would be quite a pain.
This means you would have to basically write your own code capable of parsing and manipulating MySQL files. This would be a horribly complex task.
Yes, there is a better way. If you want to use MySQL, use MySQL.
Another option would be to use the embedded version of MySQL, or something like SQLite.

Migrating from Apache Derby to MySQL

I have a JDBC application that uses Apache Derby. How can I migrate my entire database system to use MySQL?
I have 3 Java programs that access the database
I have 3 tables and 2 views
I am using Netbeans. I have never used MySQL before and do not know where to begin. Is there nice integration with Java and MySQL in Netbeans? How can I get nice integration with NetBeans and MySQL?
All help is greatly appreciated!
Looks like this plugin would probably help you:
http://netbeans.org/kb/docs/ide/mysql.html
I found this tutorial on the Spring site, but I think it is only a partial solution.
Tutorial
In it they are relying on hibernate to drop and create the tables, and I really don't like that. You have to go through special coding to add static data. For example, if your app is tracking devices, you probably want a table of device_types. At least some o those device types will be in the db, as well as devices, users, etc.
What I intend to do, is to use Derby until I am somewhat stable. From it, I will get the database schema and create it in mysql. It seems that the DB look utility can be used for that. DB Look
As added security I intend to run my web app with a db user that does not have the ability to add or drop tables. Also it is possible to remove the permission to delete rows if you use the concept of making rows "inactive" So instead of deleting a no longer used device type, you set the "active" flag to F. So your device type query would look like:
select * from device_type where active = 'T'

Using a local database for java application

I am currently undergoing a project which requires a database. So far uptil now I have been using a sql localhost database, I was wondering if there was an alternative to this.
Similar to micrsoft access database where I could read from the local database file instead?
It sounds like you are talking about an embedded database.
Take a look at: http://www.h2database.com/html/main.html
You could use Hypersonic or Derby; the latter is part of the JDK now. SQLite is another possibility.

Categories

Resources