Sqlite data with desktop application - java

I am creating java desktop application. I have created exe of my jar file using exe4j. Now i am binding my sqlite database with my exe using easy binder software. But when i run my application the data is getting saved properly but when i rerun the application the data is not there which i have saved before. Please help
I have tried using the specific path i.e. stored the sqlite db file at specific location, it is working but it is not secure as any one can open the file.
I need to embed the database along with my application but the database is not saving the data when i rerun my application.

It sounds like your data is only getting temporarily stored because SQLite is using a transient in-memory database due to the fact that it can't find the specified database. Please specify what version of SQLite driver you are using, as well as an example of its use in your code.
Is you are worried about the security of someone accessing the database, then you may wish to consider another database besides SQLite.

Related

how can i connect my java app to a local file .sql without install any server

is it possible to read data from a local file without install a server
i use netbeans
If you want to simply read and write a file you can use the java.io or java.nio packages; if you want to access an .sql file as a database: you can't. It's not a database. You'll need to install a database on your pc to do such things.
SQL files are in plain text format and can comprise of several language elements. Multiple statements can be added to a single SQL file if their execution is possible without depending on each other. These SQL commands can be executed by query editors for carrying out CRUD operations. They do not contain any tables for accessing data.
Getting started with a database is fairly simple (if you follow instructions) and Netbeans has a built-in database, but I've never used it.
You can read about mysql here for example:
https://www.tutorialspoint.com/mysql/index.htm
And on how to connect to databases here:
https://www.tutorialspoint.com/jdbc/index.htm

Create an internal Database for Java EE?

I'm creating a web application, possibly using Maven, Spring and Hibernate.
I need to create a database for the application which will obviously hold some data, however as I need to send the application to someone once it is finished so that they can run it on their machine, I am not sure how to create the DB.
I have developed Android appliations previously where I have used sqlite to create an internal database, and I was wondering if there is anything that I could use similar?
Or will I have to use something like phpmyadmin?
Thanks for any advice.

Using database file built by another app

So I am working on an app that looks up data in a database. To populate the database, I built an app that read a text and added the data to that database. Now I want to use the populated database for another app that will look for the data required by the user and the database. Where is the database file saved on the phone and how can I add it to another app?
I think you should consider using ContenProvider.
Content providers are the standard interface that connects data in one process with code running in another process
see this:
http://developer.android.com/guide/topics/providers/content-providers.html

Accessing existing SQLite database using Eclipse

I have created an android app in java using eclipse which creates a SQLite database and lets the user add data to it.
I would like to know how to access an already existing SQLite database (say, in our web server) to view and add data to it ?
I Googled it and didn't get any clear picture. Do I need to install JDBC driver for doing this ?
Thanks.
SQLite is not a client/server database.
That said, the SQLite wiki mentions some alternatives.
If you want to access a remote database from your app, you will need an interface (like a web service) that will take requests from your app and actually do the database manipulation. If you just want to access a local database from your computer, there are several utilities for it to do it graphically or you can use sqlite3 to do it from the command line. If you want to access the database through your browser, I think you need a web service for that too.

How to store data into MySQL database?

I have created a java application which stores data into MySQL database.
For that I have done the following things:
I have installed MySQL database on my computer.
I have created a database on that MySQL server.
I have created a table in the database with the required schema.
Now I want to deliver this application to various clients but my clients are not technical persons and I don't want to give instructions to each of my client to do the above three steps.
How can I integrate some functionality into my app so that it can do atleast step 2 and step 3 automatically so that the client needs to install only MySQL database.
It would be much better if the code can install the MySQL database automatically from the setup file attached with the application.
How the applications available in the market manage information?
For 2 and 3 you just need two SQL statements to run during installation: CREATE DATABASE and CREATE TABLE.
As an alternative I would suggest you to use SQLite for which your clients wouldn't need to install any database servers.
Personally, I like how Confluence (for example) deals with that:
The Confluence installation includes an embedded HSQLDB database, supplied for evaluation purposes. This is what you get when using the automatic installer on Windows.
As documented, the embedded database is Not Suitable for Production Instances of Confluence so they suggest to use an external database for production and provide detailed Database Setup Guides (installation, schema and user creation) for MySQL, PostgreSQL, Oracle, DB2, SQL Server and generic instructions for others databases.
The application will take care of creating the tables on startup if the schema is empty.
For those who prefer to create the tables manually, they provide a database creation script.
When upgrading to a higher version of Confluence, the Confluence application takes care of the schema update.
you can store data in two ways
using xampp
1st is using xampp/lampp/wampp and go to insert and just insert
using php
php used to insert data with mysql query
For steps 2 and 3 better create an OS shell script (bat or bash) that will execute mysql cli tool to create database and schema from your file
mysql -u root -p superpwd < create_database.sql
the create_database.sql better to create with help of mysqldump cli tool from your own database
Later you can include this script into your MySQL bundled installation.
I would think that you could do a data dump via phpAdmin which should script out the tables of the database along with insert statements for the actual data. I'm not a Java developer, but I think you should be able to use the functionality of the Java libraries that give you database access to turn back around and load your scripted out database as a file, read that file and then execute it against a database that you create via code.
Hope this helps for you.
For reference, here is how to create a mySql database via a command line .

Categories