Java Embedded Database (Text Database) code example

Source: Internet
Author: User
Although Java provides good database support and supports a large number of third-party persistence layer frameworks, however, compared with other languages, using database connections in Java also causes a large amount of system loss. Therefore, for systems with low data throughput, it is a good choice to discard the database and use local files to store data, for example, we usually use properties and dom4j to read data from text files or XML documents for the startup configuration of Java programs, instead of dropping data into the database, this is almost a common sense.

However, in terms of functions, the properties operation function is only limited to operations on the introduced files. Although it is suitable for simple file read/write operations, it is far less powerful than XML, in addition, multiple files may be required for configuration. Otherwise, the configuration may be messy. However, for XML, even if the common XML operation components in Java such as dom4j or JDOM have powerful functions, the emergence of a large number of elements makes the operation not as intuitive as calling properties, in addition, the processing speed of XML files is less time-consuming than that of plain text files.

However, if we use small relational databases such as access and sqllite to save the poor data, we will not be too busy with the public, and the loss will not be worth the candle.

For example, my loonframework-game framework is a java2d game development component. Therefore, it should provide a persistent storage environment that users can use to store maps, conversations, and branch plots. Regardless of the use of properties or XML, I feel that there are some limitations, which are not satisfactory (I am very lazy ~).

At this time, it would be nice to have a component that is as easy to operate as properties, and can process more complex data as XML, with some database features.

However, I was not so convenient at hand, so I had to respond to the call of Chairman Mao in yan'an, "Do it yourself, please eat and everything.

Source code: http://download.csdn.net/source/475512

This is a simple embedded database JAVA Implementation. database operations are performed in plain text mode. in nature, it is similar to Berkeley dB. It is not a standard relational database and does not support SQL statements, all operations are implemented using APIs. however, the current function is still relatively simple. Each table represents the storage area of a file. Although there is a concept of data types, currently, each data type can only correspond to one table, that is, it is determined during table building and cannot be mixed. Crud and other basic operations are supported, which is more efficient than XML operations.

The package content is as follows:

Example:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.