I use a licensed software for data processing, Nuix. It creates an embedded Derby Database to store info about the data it processes.
My question is: is it possible for me to access the database the program creates even if I do not run the program? I want to access the database from my own JVM application.
Please note: I have never used Derby before nor am I fluent in Java.
Yes, I have used RazorSQL to browse Nuix DBs. Point it to a store folder and it should display the tables. Not the easiest Schema to understand but you should be able to find what you need.
Derby, like all databases, ultimately stores it's data on your HDD or SSD. And like many others, it stores them I files. So any other program with access to the files can access the data, in theory. You could shutdown the other program and have your own program or a Derby server daemon access the files, using the same Derby Java library version.
But you will face one problem: you will not know the database schema. So it might be difficult to interpret the data you read.
Related
I need some guidance on how to retrieving data from a database.
The database is called Drug Combination DataBase and so far I'm just using a small text file that contains a small portion of the data, but the complete database is available as a 14mb sql-file. Can I load this in an efficient way during run-time in my java application so I can look up a few entries? I've never used an sql-file to retrieve data in java before so I don't know what is the best strategy.
By the way, I'm creating an application that reads large graphs and another xml database so memory usage is fairly high.
the way to connect a Java program to a database is through JDBC. the file needs to be read int and saved to a database like MySQL or PostgresQL in order to be accessed. check out this link for a good tutorial:
jdbc tutorial
I'd like to save persistent objects to the file system using Hibernate without the need for a SQL database.
Is this possible?
Hibernate works on top of JDBC, so all you need is a JDBC driver and a matching Hibernate dialect.
However, JDBC is basically an abstraction of SQL, so whatever you use is going to look, walk and quack like an SQL database - you might as well use one and spare yourself a lot of headaches. Besides, any such solution is going to be comparable in size and complexity to lighweight Java DBs like Derby.
Of course if you don't insist absolutely on using Hibernate, there are many other options.
It appears that it might technically be possible if you use a JDBC plaintext driver; however I haven't seen any opensource ones which provide write access; the one I found on sourceforge is read-only.
You already have an entity model, I suppose you do not want to lose this nor the relationships contained within it. An entity model is directed to be translated to a relational database.
Hibernate and any other JPA provider (EclipseLink) translate this entity model to SQL. They use a JDBC driver to provide a connection to an SQL database. This, you need to keep as well.
The correct question to ask is: does anybody know an embedded Java SQL database, one that you can start from within Java? There are plenty of those, mentioned in this topic:
HyperSQL: stores the result in an SQL clear-text file, readily imported into any other database
H2: uses binary files, low JAR file size
Derby: uses binary files
Ashpool: stores data in an XML-structured file
I have used HyperSQL on one project for small data, and Apache Derby for a project with huge databases (2Gb and more). Apache Derby performs better on these huge databases.
I don't know exactaly your need, but maybe it's one of below:
1 - If your need is just run away from SQL, you can use a NoSQL database.
Hibernate suports it through Hibernate OGM ( http://www.hibernate.org/subprojects/ogm ).
There are some DBs like Cassandra, MongoDB, CouchDB, Hadoop... You have some suggestions Here
.
2 - Now, if you want not to use a database server (with a service process running always), you can use Apache Derby. It's a DB just like any other SQL, but no need of a server. It uses a singular file to keep data. You can easily transport all database with your program.
Take a look: http://db.apache.org/derby/
3 - If you really want some text plain file, you can do like Michael Borgwardt said. But I don't know if Hibernate would be a good idea in this case.
Both H2 and HyperSQL support embedded mode (running inside your JVM instead of in a separate server) and saving to local file(s); these are still SQL databases, but with Hibernate there's not many other options.
Well, since the question is still opened and the OP said he's opened to new approaches/suggestions, here's mine (a little late but ok).
Do you know Prevayler? It's a Java Prevalence implementation which keep all of your business objects in RAM and mantain Snapshots/Changelogs in the File System, this way it's extremely fast and reliable, since if there's any crash, it'll restore it's last state and reapply every change to it.
Also, it's really easy to setup and run in your app.
Ofcourse this is possible, You can simply use file io features of Java, following steps are required:-
Create a File Object
2.Create an object of FileInputStream (though there are ways which use other Classes)
Wrap this object in a Buffer object or simply inside a java.util.Scanner.
use specific write functions of the object created in previous step.
Note that your object must implement Serializable interface. See following link,
I have prepared an application that is a small demo of Student information manipulation. I have stored information related to students in a MySQL DB. Now my application is working 100% on my computer. But I want that work everywhere without depending on Database! I mean I just want "WHEREVER MY .JAR FILE GOES, DATABASE SHOULD ALSO GO ALONG WITH THAT INSIDE .JAR FILE "
So anyone who is using my application or trying it, they can realize exact result of this application.
How can I make this possible? Please someone help me.
You will probably need to look at something like HyperSQL, which is a in-memory database (which you will need to populate at application start-up). Or have a look at SQLite, which is an embedded databsase, which you can distribute as a resource in your jar.
This doesn't work. MySQL is a full-blown RDBMS. You would have to install it on every computer if you want application to use it locally. An alternative would be using SQLite.
SQLite is a software library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine.
SQLite and Java
SQLite seems to be a good fit for your requirements.
I'm new to the SQLite database, and more generally, to the concept of embedded databases altogether. I'm used to creating a connection string and connecting to a remote DB server (MySQL, MSSQL Srv, Oracle, etc.). I know this question is probably quite silly, but being in uncharted waters here, I can't seem to find the answer to this on my own.
So I'm writing a Java app that uses SQLiteJDBC as the Java driver for SQLite (the app's embedded db) and am creating the tables and inserting records into them from the Java app itself. What I'd like to do is download/install SQLite on my system - completely independent of the Java app - and then write SQL scripts that will do the "skeletonizing" (creating & insertions) of the database file itself, then copy that .sqlite file into my project directory where the app can then use it.
I'm just finding it incredibly difficult to develop database schema from inside the Java app itself; just seems like an unnecessary step.
So, my question:
Is this even possible? To create, say, myProgramDB.sqlite off the command line with the SQLite tool, and then (essentially) cut-n'-paste that file into my Eclipse/NetBeans project (of course, in the right directory!) and have it work? This is also assuming I have correctly imported the SQLiteJDBC JAR into my project through the IDE. I just want to create the DB somewhere else, then copy it into my project, instead of developing the DB through my app directly.
Thanks for any insight!
Just think of the database as a normal file which your app refers to either by an absolute or relative file path, so with that in mind embed it in your project like you would any other file in Eclipse (or point to a specific location where you expect it to be).
If you're going to create your db manually, SQLiteStudio (http://sqlitestudio.one.pl/) is free tool which will help you build the schema.
It also lets you export the structure and/or data as sql statements, which you can then use to build a copy of your database elsewhere.
Is this even possible? To create, say, myProgramDB.sqlite off the
command line with the SQLite tool, and then (essentially) cut-n'-paste
that file into my Eclipse/NetBeans project (of course, in the right
directory!) and have it work?
Yes of course, you can do it. Haven't you got somewhere in your code a getConnection method call? It's used to connect to the desired database. In your case should be something like:
DriverManager.getConnection("jdbc:sqlite:" + databaseName);
I just want to create the DB somewhere else, then copy it into my
project, instead of developing the DB through my app directly.
That's reasonable. The only thing that you might consider is this: if your application depends on the database "skeleton" as you said, then a database file (talking about SQLite) must always be available in order to proper run your program. Embedding inside your application, the basic instructions to create the database tables required, could permit to the application to rebuild a minimal database if the file is accidentally lost.
There are a number of GUI schema-creation and browsing clients for SQLite.
CAVEAT:
There are some differences in the way various implementations of SQLite differentiate (or don't differentiate) between INTEGER datatype and the other ways of expressing integer, such as INT, INT32, BIGINT, etc., especially when then column is a primary key.
If creating a SQLite schema outside of the implementation where you plan to use it, use "INTEGER" (verbatim) when assigning integer data type affinity to a column; do not use any of the other variants of int.
I am making a desktop application in java and using MSAccess in data base.
I want that if i run the setup of the application the database should be created on client machine because there can be different client using the application and how can i create the setup?
is there any tools available for this free of cost?
please explain me in detail..
thanks
Java 6 (enhanced for desktop application work) comes with a built-in database called JavaDb (formerly IBM's Derby). That will do what you want.
Here's a set of guides and tutorials on how to use it.
I would suggest that when your application first starts, it checks for the presence of the created database, and if it doesn't exist, it builds the database (via the appropriate SQL). I've used this approach before and it works quite well.
I prefer nullsoft. Take a look at Open Source Installers Generators in Java
#pratap: database should be created on client machine..
Add an empty access database to your setup.
Have a look at SQLite, which is used by Mozilla (Firefox stores all bookmarks and history in a database) and several other major applications.
When you say
access in database
do you mean Microsoft Access or access the data in a database.
I would advise against MS Access if that is the case. If not, you could either use the JavaDB or HSQLDB and the use SQL scripts to create the database. As a summary
Package the application in one of the installers (InnoSetup or NSIS are good ones)
When installing, extract all the files in proper folders
Execute the SQL scripts before first running the application to ensure the database is setup, you can do other housekeeping tasks along with this step (refer to installer documentation for after-install steps)
Your application is good to go
In the last distribution of NetBeans I used, there was a wizard to create such application. The application used the Java Persistence API to store the Data.
My option is HSQLDB since it's fast, reliable and easy to use.
In the documentation it's explained how to use the standalone database mode, this is primarily used for unit testing but it fits your case too. The good thing with this is that you just connect to the file based database without any special set up and if the files doesn't exist, they're created.
I would second the posters who recommend JavaDB.
It is absurdly easy to adminster from inside your application. Whats more because everything is native Java you dont get the char->unicode little-endian->big-endien and all the other conversion malarky you normally get when reading SQL into java.
The one tip is that with JavaDB is prepare your SQL statements. Prepared statements get cached and the resulting access program (similar to an access plan but actually a jvm program) is reused, the programs for "executed' statements are not cached.
If you are really set on MSAccess then I would suggest you package an "default.mdb" file with all your required tables defined and your classifcation tables populated. If the user's table does not exist then simply copy over the default .mdb file and open that.
I recommend the H2 database because it is simple, fast, pure Java, and small. See this page for how H2 compares to other Java databases, including those mentioned here in other answers. It has many features Derby/JavaDB and HSQLDB do not.