application Java: base de données sur l'accès à un autre ordinateur
-
27-10-2019 - |
Question
J'ai une application qui utilise java et se pendant le codage, j'installé établi MySQL sur localhost, tout fonctionne bien. Maintenant, je dois distribuer les fichiers jar afin que les gens puissent l'utiliser. mais quand j'essayez d'accéder à la base de données, il indique une erreur de connexion. Dans le chemin de la base de données que j'ai remplacé localhost par l'adresse IP de l'ordinateur la base de données est activée. Est-ce que quelqu'un pourrait m'aider s'il vous plaît.
Merci beaucoup
La solution
As you know, for JDBC in general, you need to specify the host in your connection string.
As you also know, you typically specify the driver in Class.forName(), and the driver's .jar directory in your Java CLASSPATH.
You're probably using the MySql/J connector - I believe that's all your client needs deployed along with your application.
You also need to make sure the mySql port (default 3306) is open.
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.
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...
Autres conseils
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.