0

I have MySQL installed, but It takes more than 1 GB of C drive. However the database file is only some KB's. I want to help to transfer the database file into single file that is in the Java program data folder. Also i want to know how to change the connection to be that file instead of using JDBC?

Thank you.


So a fast edit after long time ago 😂 that day i meant that I want to use something like SQLite instead of MySQL I think that clarifies it now waiting for new answers.

2
  • 2
    emm do you want to connect your program directly to the file or what ? i dont understand ? Commented Feb 15, 2014 at 15:17
  • What you want cannot be done with MySQL. There is no option to connect direct to a file. While MySQL uses files internally you can't "connect" to files. Your best beat would be MySQL Connector/MXJ, but it was discontinued a long time ago. Commented Feb 15, 2014 at 15:34

4 Answers 4

3

First of all, you questions is structured in a way that i do not fully understand it. However let me make things clear.

In order for java program to connect to Database you need a driver ( typically JDBC ). The database HAS to be on some sort of "server" i.e apache, sql server, derby etc. If you want to save some HDD space i suggest looking into Derby Database, which is "integrated" database

EDIT:

Or you can just host external database on some hosting server ;), there are some free ones out there too !

Sign up to request clarification or add additional context in comments.

7 Comments

ummmm yes you didn't understand me clearly I mean I have now my own java program that uses a connection of JDBC to connect to MYSQL to get data I want a way to only have a small .db file with the jar file data that have those data I get from the JDBC so instead I use a big connection from java to mysql I only make a small connection to a small .db file that is located with the data of my JAVA (jar) program understood ?
@user2919656 sorry but i still dont get it. What do you mean by saying "...I use big connection from java to mysql" and that you want to ".. make small connection"
my english is not good :P I mean that I have MySQL installed in the C drive it takes about 1.5 GB and I see lots of other Java Or C ++ programs that Have a small File named *.db and have the data needed I want to know How to do something Like that (have a small size of some KB and can be transferred on a USB withing the Jar) instead of re installing my SQL and copying the data on any computer I want to use my program with I think It's Clear now .. ?
I think i do know what you mean. What you are referring to is probably a MySQL Program. What you can do is open MySQL program containing your database and find an option to " Export Database to a file ". This will give you option to save the database into a file (it wont be big ) However to access this database you will still need some program / host where this .db file can be uploaded
okay you understood me now I will search for that export option now if you please teach me or show me an example how to remove the JDBC connection from the main MYSQL to reset it to just connect to that file I exported ?
|
1

You might want an embedded database, like h2 or java Derby.

Such an embedded database often is stored as file, without external database engine runnin (it might do that too though). The API remains JDBC.

1 Comment

+1 for h2. It can even emulate MySQL to some extend
0

What I needed was mySQLite, it's saved on the device as a single file and easily managed through java.

Comments

0

What you need to do is to export the mysql database And use dbmigration app to convert it to sqlite then use your database as you wish

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.