9

I guess I'm just not "getting it". If I don't have SQLite already installed on my computer, and I want to write a Java app that uses an embedded database, and I download/import the SQLiteJDBC JAR into my project, is that all I need? Or, do I need to first install SQLite before and create a database file for my SQLiteJDBC code to connect to and run queries from?

If that's the case, and its not sufficient to just download/import SQLiteJDBC, then doesn't that mean that I'll have to make sure SQLite is installed on every system that I want to run my Java app on? And doesn't that defeat the purpose of a portable/embedded database?

Basically, I'm getting hung up on the SQLiteJDBC tutorials because:

  1. They don't tell you how HelloWorld.sqlite gets created (does SQLiteJDBC create it for you, do you have to create it in SQLite first from the command prompt, etc.); and
  2. They never clarify whether SQLiteJDBC is dependent on SQLite for the API calls to work

Any help here is greatly appreciated!

Paŭlo Ebermann
  • 73,284
  • 20
  • 146
  • 210
Massie
  • 165
  • 1
  • 2
  • 5
  • H2 is a good pure Java alternative (single jar dependency), which can be used as in memory, file based or in server mode. – 01es Aug 13 '11 at 17:07
  • Hello Massie, welcome to Stack Overflow! – Please try to find a bit more descriptive titles (like the one I just edited) in future – this way your questions will be easier to answer, and also more useful for future visitors. As a side note: You can format numbered lists by simply putting the numbers (`1. `, `2. `) instead of using HTML. – Paŭlo Ebermann Aug 13 '11 at 19:27

1 Answers1

6

You have to put the SQLLite JAR in the CLASSPATH of your app. There's no "install" beyond that.

Maybe this tutorial can help you.

Here's another that shows how to create a database and tables.

duffymo
  • 305,152
  • 44
  • 369
  • 561
  • I'm in NetBeans. Does that mean Project Properties >> Libraries >> {Compile, Processor or Run} (which one)? Then, once it is added to the CLASSPATH, and I want to use con = DriverManager.getConnection("jdbc:sqlite:HelloWorld.sqlite"); as my connection string, does SQLiteJDBC create the HelloWorld.sqlite database for me automatically? And thanks for the hint! – Massie Aug 13 '11 at 17:13
  • Add it to compile. No, it doesn't create the database for you. You have to do that and create the tables, too. – duffymo Aug 13 '11 at 18:58