views:

115

answers:

9

I had completed my project Address Book in Java core, in which my data is stored in database (MySql).

I am facing a problem that when i run my program on other computer than tere is the requirement of creating the hole data base again.

So please tell me any alternative for storing my data without using any database software like mysql, sql etc.

+4  A: 

I would suggest using an embeddable, lightweight database such as SQLite. Check it out. From the features page (under the section Suggested Uses For SQLite):

Application File Format. Rather than using fopen() to write XML or some proprietary format into disk files used by your application, use an SQLite database instead. You'll avoid having to write and troubleshoot a parser, your data will be more easily accessible and cross-platform, and your updates will be transactional.

karim79
Generally that's not a bad approach, but since the application seems to already use JDBC, an embedded JDBC-capable DB is probably the better match here. Also: from what I see SQLite isn't particularly Java-friendly. Am I wrong here?
Joachim Sauer
@Joachim Sauer - I really wouldn't know, as I have never used the two together. I did however think it was worth suggesting.
karim79
there is SQLJet. >>>pure Java implementation of a popular SQLite database management system.Although I haven't used it either.
Fakrudeen
A: 

If you data is not so big, you may use simple txt file and store everything in it. Then load it in memory. But this will lead to changing the way you modify/query data.

Ilian Iliev
ya somewhat this type of suggestion i need.plz tell me hw to store data in text file
Ravi
If you have a single kind of data(one table in RDBMS) the simplest(by my opinion) variant is to store the date from each row from the base as CSV in the txt file. Then read it line by line. Split by separator and use it.Hope this help )
Ilian Iliev
+5  A: 

You can use an in-memory database such as HSQLDB, Derby (a.k.a JavaDB), H2, ..

All of those can run without any additional software installation and can be made to act like just another library.

Joachim Sauer
+1. but Ravi should note that the data will be lost when the application is closed.
Bruno Rothgiesser
@Bruno: not necessarily. HSQLDB can be configured to read and write its database to a file. I have no experience with the other ones, but I'm pretty sure that they can do the same.
Joachim Sauer
@Joachim: yes, that actually makes sense. I see no reason why the db wouldn't have a feature to dump the data in memory to a file, from which it could be loaded later.
Bruno Rothgiesser
Actually the problem that i m facing is installing database and than use the same database on all pc,sI want to make it global so that any one can use it, just like they use other Address storage software.
Ravi
+2  A: 

The whole point of StackOverflow was so that you would not have to email around questions/answers :)

You could store data in a filesystem, memory (use serialisation etc) which are simple alternatives to DB. You can even use HSQLDB which can be run completely in memory

Calm Storm
Hey Calm please tell me to do this all in Java.and if there is any software which help me to do this and that is compatible with java.please do tell me.
Ravi
A: 

Database software like mysql, sql etc provides an abstraction in terms of implementation effort. If you wish to avoid using the same, you can think of having your own database like XML or flat files. XML is still a better choice as XML parsers or handlers are available. Putting your data in your customised database/flat files will not be manageable in the long run.

Why don't you explore sqlite? It is file based, means you don't need to install it separately and still you have the standard SQL to retrieve or interact with the data? I think, sqlite will be a better choice.

Kangkan
A: 

if your problem is creating the schema (creating the tables, indexes, foreign key relasionships etc) than try something like hibernate. hibernate is an Object-Relational-Mapping (ORM) library that "hides" SQL from you - as far as youre concerned youre magically saving your objects and retrieving them. it relies on annotations you provide on your data classes. hibernate can be configured to create the appropriate tables if it discovers they are missing (like the first time you run your application after a clean install)

hatchetman82
A: 

Just use a prevayler (.org). Faster and simpler than using a database.

Stephan Eggermont
A: 

I assume from your question that you want some form of persistent storage to the local file system of the machine your application runs on. In addition to that, you need to decide on how the data in your application is to be used, and the volume of it. Do you need a database? Are you going to be searching the data different fields? Do you need a query language? Is the data small enough to fit in to a simple data structure in memory? How resilient does it need to be? The answers to these types of questions will help lead to the correct choice of storage. It could be that all you need is a simple CSV file, XML or similar. There are a host of lightweight databases such as SQLite, Berkelely DB, JavaDB etc - but whether or not you need the power of a database is up to your requirements.

Miles D
A: 

A store that I'm using a lot these days is Neo4j. It's a graph database and is not only easy to use but also is completely in Java and is embedded. I much prefer it to a SQL alternative.

gpampara