本文介绍了在JDBC Sqlite中创建数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是来自
的SQLite驱动程序
上述文档中显示的示例显示了如何连接现有数据库。

I am using the SQLite driver fromhttp://code.google.com/p/sqlite-jdbc/wiki/IntroductionExamples shown in the above doc shows how to connect an existing database.

在我的应用程序中,我需要创建一个SQLite数据库。怎么做?创建扩展名为 .db 的文件是否足够?
还有一个名为 createFile()的函数。如果是这样如何使用它?我用谷歌搜索,没有人给出明确的答案。

In my application I need to create an SQLite database. How to do that? Is it sufficient to create a file with extension .db?Also is there a function called createFile(). If so how to use it? I googled and nobody is giving a clear answer.

推荐答案

如果文件不存在,SQLite会在第一次尝试连接时创建新的数据库文件已经。

SQLite creates new database file on first attempt to connect if file did not exist already.

所以,只需使用 jdbc:sqlite:filename.db 作为JDBC连接字符串,并提供给你有权创建 filename.db ,它将自动创建。如果需要,您也可以使用 0 大小手动预创建此文件。

So, simply use jdbc:sqlite:filename.db as JDBC connection string, and provided that you have permission to create filename.db, it will be created automatically. You can also manually pre-create this file with 0 size if you want.

这篇关于在JDBC Sqlite中创建数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-22 15:12
查看更多