Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
82 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...