Search code examples
javamysqlnetbeansjar

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


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.


Solution

  • 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