Jar file can't access Mysql database when moved to another computer - java

What the title says, basically. I have created a program for managing a database, and it worked perfectly inside and outside of the Netbeans IDE. However, as soon as I move it to another computer it can't access the database anymore. I don't know what the problem is, both computers are on the same LAN so they should be able to access the same localhost.

Your url is:
jdbc:mysql://localhost:3306/javabase
localhost is only valid on your local computer. If you want to access a database on another computer you have to use the hostname or the IP address of this computer.
For example:
jdbc:mysql://192.168.0.110:3306/javabase

Related

Export MySQL Server database to file

I have recently put all my java EE projects into my google drive so i can access them on my laptop and desktop computer. Some of my projects have a database component which I have the database stored in a MySQL server. Is there a way that I can export this database and just access it from like a database file which I can store in my project file so I can use it on both my laptop and desktop computer?
This is really what I would like:
-Be able to work on my java EE projects that have a database on both my computers
-Store my MySQL Server databases in a file which can go in my project folder then use java to access that database instead of going through the server
Any alternate ways of doing this would help me out this is just one way I can think of doing.
Note: I am using my laptop on the go so my desktop computer wont always be accessible from my laptop neither will I have an active internet connection always.
Thanks
Install MySQL on your laptop, then transfer database using backup/restore, e.g. using mysqldump. See https://dev.mysql.com/doc/refman/5.0/en/backup-and-recovery.html

How to get system name dynamically?

Please I have a Java Desktop app which connects to a MySQL database and I would like to run the application over a network.
This is what I've done so far.
My Java application generates a batch file that points to the original local of the .jar file so I simply place this batch file in other client systems and run them so they simply find the .jar file on the server system and open the application.
But I have an issue, I have a scenario where I don't know the server's system name so I can't specify it in the MySQL database connection string.
Please how can I dynamically get the system name and pass it into the database connection string so the client systems can also connect to the same server or database?
you may find it useful if you want to know how could we get username of any host System.getProperty("user.name") returns HOSTNAME instead of currently logged username
This may help you
import java.net.InetAddress;
Code
String myip=(InetAddress.getLocalHost()).toString();
Here you will get pc name and ip address with a '/' separated
String data[]=myip.split("/");
System.out.println(data[0]); // Machine name
System.out.println(data[1]); //Ip address

connecting from android mobile app to a database on a laptop

I'm new to android programming so please I need your help
I want to make a mobile application that connects to a databse on my laptop through internet without configuring my router
I'm using phpmyadmin in which i created a database, and I made a file called login.php that can make sure of username and password from database
I enabled the port 80 in firewall
now i wrote in eclipse this url : http:"//192.168.1.3:80/Day%20Manager/Login.php"
the ip address is optained by writing ipconfig in cmd and getting the IPV4 address
well it's not working it's giving me NetworkOnMainThreadException
can you help me please
Have a look at this link. This might help. Ofcourse if you are going to need to access it from your application you would have to provide an intermediary php script to get it working correctly.
you said you are using phpmyadmin database, then place your php file in c:/>xampp/htdocs folder, open your browser and enter localhost/login.php then you will get output, in the same way connect to url from program then you will get the data.
note: make sure internet permission in manifest file.

Java Establish connection to a network computer

I have a program that needs to read/write files to/from a network computer. Sometimes however the program cannot access the folder on the network computer. Currently, to fix this issue, I go into windows explorer's network section, click the computer, enter my credentials, and then my program is able to read and write to this computer without a problem. Is there a way to allow Java to ask for these credentials or a way to automatically send these credentials using java? I am using Win7 and Win7 embedded on the network computer.
You can use http://jcifs.samba.org/ which is a library for accessing remote CIFS shares. This allows you to set username and password and works on any platform (not just windows) It works without needing to mount a drive.

How to access shared folder on Windows without prompting username/password?

My selenium and java based application needs to frequently read/upload a small-size file from a shared folder (\\some-server-ip\SharedfolderName).
When I run the application on multiple client machine (both server and clients can see their IPs) I am prompted to provide username and password to connect to server IP before the application can access the shared folder.
I have shared folder given full control privileges to everyone, anonymous logon group.
I also added \\some-server-ip\SharedfolderName to local security policy's
Network access: Shares that can be accessed anonymously
But, it is not working.
Interestingly, if I enter the username/password manually first time, it works fine in subsequent runs on that particular client. I cannot manually enter username/passwords on all 700+ of the client machines.
I have been trying to get this to work from past three days, without much success.
Any help/suggestion would be greatly appreciated.
P.S. I have been trying different OS (2008, 2003, Win7) for hosting the shared folder, in a desperate hope to get it to work somehow.
try mapping network drive on your client ?

Categories