使用java创建本地mysql数据库,Java读写本地数据库?

I have a program which is constantly getting information from a website and is constantly updating. As of now I store all that information in an arraylist and then when I am done I write it to a text file.

I need to manipulate that information; however, it creates a massive text file and I can't constantly read and write information to a text file because it takes too long. So someone told me to look into using a database. The only database I have ever used was a MySQL database for a website, never with java.

Is there any way to make a database local? As in only on my computer (don't want to pay for web hosting when I am the only one accessing this information at my computer)? I was looking a little bit into SQLite but one of the things I saw was that it does not allow concurrency. I'm thinking of multi-threading my program and having it read and write different sections at the same time. Is this possible?

Basically what I'm asking for here is:

What type of database should I use?

How do I install that database on my computer?

Some information on how to use Java jdbc?(was reading a little into it before)

Any tutorials on any of the above (video, text, etc)

解决方案

It sounds like your friend is correct and a database would greatly help you improve performance.

You can really use any type of database. You can even continue using MySQL by installing it locally and using Connector/J to connect in Java. Though embeddable databases are probably the easiest. One option is Hypersonic DB (HSQLDB)

There is no need to "install" embeddable databases. Simply add their library (.jar file) to your project's build path. When you "connect" to the database, you can usually tell the database to use a location on your filesystem to store its data.

JDBC stands for Java DataBase Connectivity. It is the API used by Java applications to communicate with databases. One of the important features of JDBC is that it (usually) does not matter which database you are talking to as the API for accessing any database is the same*.

Here is one tutorial for JDBC: JDBC(TM) Database Access

*The API for accessing databases--e.g. sending queries and retrieving results--will generally be the same but JDBC can't hide differences in things like SQL. If you use an ORM like Hibernate, it can usually make it much easier to handle all the little incompatibilities between databases.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值