Exporting eclipse java Desktop base application with database MySQL - java

I have created my project in eclipse which is a Timetable application and database MySQL is used for data. now i want to run my application on clients computer i have created jar file and exported database file. the problem is i am unable to understand how to connect database on clients computer, even if i will install server but how will program find database location?

There are two cases here:
Case 1: The DB that you used to connect to the application is in the same network as your client's system, then you can use the same DB.
Case 2: If your client is in different network, then you need to install a DB there and replace the connection strings that you used to connect to your DB with the new connection strings. These connection string are nothing but URL to the DB with username and password which of course you would know.
Regarding your doubt, If the DB is installed at your clients, the DB shall be available at a local IP address. Use this local address to connect form your clients application. When applications are in the same network, they can identify each other.
Hope that paints a picture.

Related

Distributed application in a LAN with one DB server

I plan on making a distributed application where 10-15 computers are connected in a LAN and there is one server where the database will be stored, also inside the LAN.
For the purpose of the question lets say the application will be made using Java and the database will be MySQL, but that is not yet decided.
So the question is, what do I need to realize this?
I have ofcourse worked with MySQL databases, but on a single computer so I am not quite sure how to connect the computers to the database server. Is it enough to setup the server local IP on all client computers and connect to it using the JDBC MySQL driver, and after that I can work with it like the DB is on my machine?
Also, do I need a server application to manage connections to the database, so that there are no conflicting entries? And if I do, then the connection part changes, because it needs to be established over the server application, so how do I do that?
I know it is a large question, but a lot of things seem unclear, because I have never attempted a project this big.
Thank you all!
Don't worry just made your application, you can connect to your database via an #IP, so just make a part of configuration in your application to change some information in future:
String db_url = "jdbc:mysql://192.168.0.1/db_test";
Is it enough to setup the server local IP on all client computers and
connect to it using the JDBC MySQL driver, and after that I can work
with it like the DB is on my machine
You don't need a server local of every computer, you can connect to the server directly.
Also, do I need a server application to manage connections to the
database, so that there are no conflicting entries? And if I do, then
the connection part changes, because it needs to be established over
the server application, so how do I do that?
If you are using a desktop application, the you don't need a server application, else if you are using a web application, yes you need one.
You need to shouse a server application, this dippend of your project or your company, there are free servers like GlassFish, Payara, Apache Tomcat, Wildfly and more.
Now the connection to your database, there are many ways to connect to your database, if you are using JPA to connect to your database, then you will hear
something about Entities, Facades, JNDI so this generally be configure in your server
application.
Hope you get an idea.

Accessing MySQL Database on XAMPP From a Remote Machine

I am trying to access a my MySQL database thorugh a program I have written that is currently being stored and run on XAMPP on my local machine. I'd like to connect to it from a different machine that is on the same network so they can access the database read/write etc. I am however having no luck in connecting. I've packaged the Java program into an exe that I am running on the remote machine. I've tried a number of solutions already;
I've created a user in PHPMyAdmin that can connect from any host, and has all priveleges granted on the database in question.
I've edited my program for the remote machine so that "jdbc:mysql://localhost/sdcjobs"; is now "jdbc:mysql://(theipaddressofmymachine)/sdcjobs";
I've edited my ini file (C:\xampp\mysql\bin\my.ini) so that bind address is uncommented as now bind-address=0.0.0.0
One of the main question marks for me is what software needs to be installed on the remote machine. On my machine (the one thats running the server) I have XAMPP installed that is running an Apache server and a MySQL database. On the remote machine I've installed nothing aside from my Java program, does the remote machine also need MySQL installing on it?
Have you tried to connect to your remote database with tools like mysql workbench or heidisql? If this does not work too, it could be a configuration issue in your my.ini
Please don't forget to restart your mysql service after changing your config.
Take a look at the mysql docu: http://dev.mysql.com/doc/refman/5.6/en/problems-connecting.html

java application not connect with a specific database in mysql on localhost,connection refused error comes

My java application is not connect with a specific database in MySQL on local host.'Connection refused' named error coming when I am trying to connect.
I have checked also service of MySQL its working because there is two db on local host, I am able to connect with one Db. I have googled all the things but my problem still not resolved.
Please check the Bind address
(https://dev.mysql.com/doc/refman/5.1/en/server-options.html#option_mysqld_bind-address) to see if you have altered the my.cnf|ini configuration file on mysql correctly.
Also if you are trying to connect using different machine then you have to create a user and grant him privileges like this to make the database available remotely
CREATE USER 'jeffrey'#'%' IDENTIFIED BY 'mypass';
GRANT ALL ON db1.* TO 'jeffrey'#'%';
Wildcard % is used to give access to any IP connecting your machine.

Trying to connect sql database which is on host

I'm having trouble with trying to connect sql database which is staying in a host machine. I know host machine's ip,password etc etc I can use this host maching as my computer. So here's my problem starting. Normally my database stands at my C:/ folder like "x.sqlite" I did this database with mozilla plugin which named SQLite Manager. Here's my code for connecting to database.
Class.forName("org.sqlite.JDBC");
Connection conn =DriverManager.getConnection("jdbc:sqlite:C:\\x.sqlite");
But i need to connect first host machine and show the sqlite file as that code which i gave before that. If you need something, just leave a comment or if you have any answers , feel fre e to share with me please , thanks ^^
SQLite is not designed for use over a network. If the remote database is available as a network share or NFS mount you might be able to use it, but that is likely to cause data corruption if the connection goes down or has temporary glitches.

App Java and hosting mysql

I have a Java application and I have to connect to a MySQL DB host in aruba.it. If I make a connection, aruba.it refuses that. How to solve this?
To start, I assume that you're trying to run this Java application locally, or at least at a different machine than where the MySQL DB runs and that you got a SQLException: Connection Refused.
To fix the particular problem, all routers and firewalls in the complete network pipe between the client (where the Java application runs) and the server (where the MySQL DB runs) needs to be configured to allow/forward the port number which the DB uses. This is by default 3306. If this port is blocked, you cannot reach the DB from outside.
Another solution is just to upload the Java application in flavor of a webapplication and run it by HTTP. You'd normally use JSP/Servlet for this.
Apart from network, routers, firewall issues the reason can be that by default remote access to MySQL database server is disabled for security reasons. Mostly DB is hosted on the same server or on the trusted server. If you run java application from your desktop, you need to configure MySQL so it will accept this connections. See this manual for details how to do it.

Categories