I have developed a demo application in java.It has a simple log-in screen that has username and password fields.Now,i am using sqilte for the purpose.I am able to log in to by connecting to the predefined database.But i want to run the application in a different machine with successful log in.For this purpose I want to create a database in the different machine automatically from the application if it does not exist.For that I want to package the application in to an executable installer and install in a different machine and run it.Sqlite being an embedded database what is the exact solution to it?
-
I just created that application experimentally...just to check whether it's possible or not.user2735799– user27357992013-08-31 16:36:07 +00:00Commented Aug 31, 2013 at 16:36
-
You can reword this question to ask how you include a SQLite database as part of your Java application, i.e. how to package it and where the file should be located (etc).Ben– Ben2013-09-01 09:39:03 +00:00Commented Sep 1, 2013 at 9:39
-
Where is code ?Hardeep Singh– Hardeep Singh2017-09-18 06:09:28 +00:00Commented Sep 18, 2017 at 6:09
Add a comment
|
2 Answers
Just include a default/sample SQLite database file in your installer package or application. SQLite isn't magic, it's just a file on the filesystem.
From: Creating Database in JDBC Sqlite
The SQLite JDBC string you're using contains the filename of the file you should copy:
jdbc:sqlite:filename.db
The file filename.db will be in your application's working directory.
Comments
Take a look at Creating Database in JDBC Sqlite.
Then you can use create table if not exist to create your tables and relations.
2 Comments
user2735799
how to achieve that(create table if does not exist) ?...could u elaborate that?
JackTools.Net