How to put the MySQL database in the folder with the java project so that the program connects and behaves appropriately with this database, if it is possible of course.
Related
I have a multiple tables MySQL database for my project. I am using XAMPP Control Panel to reach it localy. Everything is okay, but I have to deploy this project to Heroku. Is there any way to store the database in my project directory or any alternative solution? I know that H2 database can be stored. But for me I need MySQL now.
Recently, I constructed a java application that uses JDBC in order to connect to mysql. The question is this: if I export the java application as a jar file, does the database itself gets exported with the jar file? In other words, can the application still connect to the database (mysql) on any pc?
No you can't, JDBC is an API that defines how a client interacts with the database, it's a separate thing.
I have developed an application which works with derby database, all things are ok on my machine, i started the database server from the netbeans.
Is there any method to copy the database structure and data for distribution to my clients?
All you need to do is to copy the contents of the database folder as is.
The database directory consists usually of one file service.properties and two directories: log and seg0.
If your application is the only one accessing this database on the client, then you should consider to use embedded mode, to avoid the installation of the Derby network server.
I would like to ask a question about jar and database connection. I performed an application and converted to jar file. Jar file works if I open NetBeans's Service which is server(I have created my tables on jdbc:derby://localhost:1527/sample). But I want to open jar file without opening NetBeans and its service server. The application should work on other PCs if the jar file clicks.
I have searched a lot about this but I do not know how I can do. For example, if I use file database (MSAccess) with ucanaccess driver, will this support JPA(Entity Beans) and JDBC ? Because I have used JPA and JDBC together in my application. I have also searched embedded database but when I create the embedded database and table, I can not access table. It gives me an error which is "Table/View does not exist".
Please help me.
What should I do if I use JDBC and JPA together in my application ?
And If I want to open the jar file other PCs and they can reach database information, what should I do ?
Best regards.
I am new to derby+Netbeans, but from your explanation and this link -
https://netbeans.org/kb/docs/ide/java-db.html#configuring
It seems you are using internal Java DB which comes with Netbeans Glassfish server.
Therefore when you start the server from netbeans it works.
Try external installation of database as shown in the above given link. It should work outside Netbeans.
I make a java application using netbeans that connect to database , but i have a problem , i want to embed mysql database with the executable jar file , so when i take this jar file and run it on any pc that doesn't have mysql server it will run with database , i thought about include the mysql-installer.exe and make a script to install the mysql server , but i can't find how to do that ,also i read about Connector/MXJ does it work if the user run the application and he does not have mysql server , any suggestion or article about this.
Derby is a pure-java DBMS. You bundle the derby jar with your program, just as you would any other library. This is a much cleaner way of ensuring your user has a db for your program, as you're not adding any dependencies.
Usually distributors don't include standalone databases, such as MySQL or Oracle, with their
application. If needed, they provide SQL script to build the database and make the user type in the database host, username and password and make a script to build the database. If you want to "ship" the database with your application then I would consider more lightweight databases such SQLite (singe file database).