How to embed database to in an application? [closed] - java

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I download a small desktop application.This application stores many information.How they embed database into an application without database setup in computer.I made several search but i don't really understand.
-Are they store this kind of information in txt files?
Thanks in Advance ...

Databases usually thinks in records. If you compare a database table with an Excel spreadsheet that would be a complete row. When you define the database table, you need to tell the database how much space each record will need so it is easy to calculate where any given row number is located simply by multiplying the row number with the space needed for each row.
In the Windows and Linux world most databases are designed to be stand-alone and the various programs needing their services connect with TCP/IP.
Some can also run embedded, where they are part of your application and only service that application which then can fully configure the database. For Java, a typical example is Apache Derby.

You can use sqlite, that is very aprropriate for your purpose.
See http://www.sqlite.org/whentouse.html

There are many ways to save the data. An Application can use simple text files, proprietary binary files or even a full embedded database like SQLite.
For C# there is an easy way like using the application properties, which are automatically saved to disk by the Framework.

Related

How to share a Java Project with a JDBC and a SQL connection? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed yesterday.
Improve this question
I made a french conjugator GUI using Java. I also created a SQL Database which had all the french verbs that users could pick and choose using SQL Workbench and connected it to the project.
When I tried to share it with my friends, they were able to access the Java project and see the various GUI elements, but none of the conjugations came up. I shared the database as well exported in the .sql format.
What can I do to fix this problem?
Probably you are using a data base like MySql or PostgreSQL .., like that all of your friends need to install this data base into their machine and have the same configurations as yours.
The first solution (simple) is to use an internal data base like : JavaDB,
SqlLite .
The second solution is to put a script that will be run within the
first execution of you Desktop application / the installation of your
application, this script will downloed the DB use and configure it,
create the tables and do the Job.

Simplest Distribution Method for Java Front-end Database Application? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 10 months ago.
Improve this question
I would like to create a front-end application in Java to query a Microsoft SQL database. This application will need to be distributed to around 20 computers and must be extremely user friendly. I'm hoping someone can explain two things:
The simplest way to distribute this application across multiple windows machines. I.e.least amount of software installation and maintenance.
Explain how once distributed, the application might be able to connect to the database upon launch, as opposed to authenticating a user each time.
So far I plan to use Java, JavaFX, & Microsoft JDBC driver. Open to new ideas though, cheers in advance.
For distribution, I can think of a couple of choices:
IF you are sure that each of you 20 computers has a JVM installed, you could package the app as a "FatJar", a single Jar file with all of the dependencies in it. There are plugins for this in both Maven and Gradle.
If you don't have a JVM on these computers, and don't want to have to install one, you could create a native application using GraalVM and Gluon.
Take a look at https://gluonhq.com/create-native-javafx-applications-using-graalvm-22-builds-from-gluon
If you want to connect to the database without user intervention, see sql server login credential for jdbc

Java Data Base Overflow? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
My code is simple, it generates a Data Base to store certain data (obviously), but the problem resides in the fact that it would create an "overflow" of DBs becuase every time the class ran it would generate another Data Base, I heard of a command:
CREATE DATABASE IF NOT EXISTS insertYourFavoriteName;
But some people say that why should I need a DB for each computer, when I could just do a central one when users conect, but correct me if I'm wrong, that would make the app depend on internet, right?
So in resume here are the 2 questions:
Does the command mentioned above works? Or does a better version or way to work around it exists?
Data Bases where all users connect to it mean that you need a server, and as a consecuence your app would depend on internet?
If you want to learn about databases you practice basic CRUD operations on that database. After that do some sample applications on database
If you want to create a database if not exists in mysql simply use this CREATE DATABASE IF NOT EXISTS DBName;
Basically before checking all these things you have to have basic understanding of what is database and how it works, So, please go through some good resources and get good understanding on the concepts.

What is the best way to save a lot of links? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I am working on a program which gets all links from a website to use them later on. I am using the Java library JSoup to get the links form the website.
My problem is that I don't know where to store all links for later use. Every link has some attributes like "used" or "not used" and the date when it was used. It should also be Windows and Mac compatible. The saved data should be updateable, editable and the program should read the file where the data is saved fast.
Does anyone know a way to solve my problem?
Edit:
As my question wasn't clear for everyone here's a simpler question:
Should I store the links with their attributes in a database or in a file?
If you need to store on a single file I'd go for SQLite. It's a SQL database provider that can save a whole database on a single file. SQLite databases are universally portable.
EDIT: As #bigdestroyer commented, Apache Derby is pure Java and may be another interesting option for you. I haven't used it though, but there is a nice comparison here.

How can I create Database and Tables within a Java application? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I would like to create a program in Java, that manipulates data and saves them physically on disk(in text file). I would like to create a simple program that allows you to insert a course, edit it, delete it. The program is stand-alone, so I would create an internal database in the application, create and save various tables with data on the user machine's, so that I can use the program on any computer.
How can I do it? I tried to take a look in the forum, and I found that Derby or HSQL can do these things; I tried to read the documentation and do some testing, but I just can not understand (I'm at the beginning), where data is saved? in which file? where tables are created?
If you can give me a help I would be grateful, even with a few simple example of creating a database and a simple table.
My question is: I would my program (executable), had within the structure of the database, and on each machine where I run I can insert, edit, delete a course, then create the various tables on the computer that I'm using. How can I do it?
Thank you so much for your patience and for your help.
You can do it easily.
The general algorythm will be the following :
start program
test presence/connection to database => ask to create a new database if file backed, or ask for a new connection
test existence of tables (exception on a simple select) => launch table creation commands in JDBC (*)
normal processing
(*) my create tables script generally begin with DROP ... IF EXISTS to start from a clean place
just to start as a beginner create a program and save that data in any .txt file with java code using filing. make sure that make your classes serializable. and then you can get, edit and delete from that.

Categories