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.
Related
I have MySQL installed, but It takes more than 1 GB of C drive. However the database file is only some KB's. I want to help to transfer the database file into single file that is in the Java program data folder. Also i want to know how to change the connection to be that file instead of using JDBC?
Thank you.
So a fast edit after long time ago 😂
that day i meant that I want to use something like SQLite instead of MySQL
I think that clarifies it now
waiting for new answers.
First of all, you questions is structured in a way that i do not fully understand it. However let me make things clear.
In order for java program to connect to Database you need a driver ( typically JDBC ). The database HAS to be on some sort of "server" i.e apache, sql server, derby etc. If you want to save some HDD space i suggest looking into Derby Database, which is "integrated" database
EDIT:
Or you can just host external database on some hosting server ;), there are some free ones out there too !
You might want an embedded database, like h2 or java Derby.
Such an embedded database often is stored as file, without external database engine runnin (it might do that too though). The API remains JDBC.
What I needed was mySQLite, it's saved on the device as a single file and easily managed through java.
What you need to do is to export the mysql database
And use dbmigration app to convert it to sqlite then use your database as you wish
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.
I need SQL functionalities for a Java JSE application, but dont need a whole SQL server, with things like listen on a port, connection string or even a standalone process to be runned or configured.
I also would prefer to work with files as storages, so that file path identifies DB data.
So given to the DB API the name of a file, I would need perform SQL with the file as DB storage, supporting tables, search, joins and inserts, without thinking to things like ports, external processes, server installation, ecc..
Without any other configurration action, since any other configurable feature is not needed.
Is there some library, preferrably installable as single .jar, that provides this functionality?
If there is not this library, which file-based DB is the simplest to configure and use within JSE, and which configuration steps are needed to perform a query in the provided DB and deploy it with (working) the java .jar application?
I suggest Derby db.apache.org/derby/
I like H2 Database very much. It compares very well with other database engines.
Sure, Hypersonic SQL or Derby, the database that comes bundled with Java 7, will both fill the bill. SQLite would be a third alternative.
you may want to check this out:
http://www.sqlite.org/
I have used HSQLDB in the past and liked it. Depending on what your needs are, you might also be interested in JoSQL which allows you to do SQL type of queries on java collections.
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.
I need to fetch DB2 data from user libraries on an IBM i machine using Java. I'm using JTOpen400. Can anyone please help?
You have to rephrase your question. RPGLE files does not exist on an iSeries. Everything is a DB2 table (which can be used with RPGLE offcourse).
If you have JTOpen400, then I advice to use JDBC. With JDBC the iSeries is a regular DB2 database server. It works like any other database server. Just follow the JDBC guidelines as describes in many books, manuals and websites.
Check SequentialFile for this. Remember to set the record format, and then you can pick out the fields for each line as you iterate them.
You can use JDBC (driver provided by JT400) to access DB2/400 files on the iSeries just like any other database.
The JDBC URL would be something like jdbc:as400://system-name/default-schema;properties
See http://javadoc.midrange.com/jtopen/com/ibm/as400/access/AS400JDBCDriver.html for more information.