Question

I have an application that uses java se and while coding it I installed mysql workbench on localhost, everything works fine. Now I have to distribute the jar files so that people can use it. but when I try accessing the database it says connection error. In the database path I replaced localhost with the ip of the computer the database is on. Could someone please help me out.

Thanks a lot

Was it helpful?

Solution

  1. As you know, for JDBC in general, you need to specify the host in your connection string.

  2. As you also know, you typically specify the driver in Class.forName(), and the driver's .jar directory in your Java CLASSPATH.

  3. You're probably using the MySql/J connector - I believe that's all your client needs deployed along with your application.

  4. You also need to make sure the mySql port (default 3306) is open.

  5. Mysql "users" are defined and authorized on a per-host basis. You'll also need to make sure this is set up correctly in your "Users" mysql table.

  6. Be sure your application logs all available exception information. Please post any specific error messages here.

'Hope that helps

PS: The only relevance to "mysql workbench" is that your app happens to work when you run it locally, using mysql workbench, correct? If so, it probably isn't a good tag for this question...

OTHER TIPS

Run the query on the DB as admin user.

GRANT ALL ON db1 TO 'jeffrey'@'%';

Assuming that db1 is your schema and jeffrey is the user you want to give access to.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top