如何将java与wamp mysql服务器连接
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20064632/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to connect java with wamp mysql server
提问by Nitin
I am new java programmer, I try to setup jdbc connnectivity with wamp mysql server.
我是新的 Java 程序员,我尝试使用 wamp mysql 服务器设置 jdbc 连接。
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection( "jdbc:mysql://182.73.151.36:3306/sbtsystem?user=sbtuser&password=Pm@dmin&useUnicode=true&characterEncoding=UTF-8");
182.73.151.36
this is server IP address. I can't understand how to connect java with wamp mysql server
182.73.151.36
这是服务器IP地址。我无法理解如何将 java 与 wamp mysql 服务器连接
采纳答案by Kuldeep Choudhary
Try This:
尝试这个:
First run these commands
首先运行这些命令
ping 182.73.151.36
telnet 182.73.151.36 3306
And make 182.73.151.36 mysql eligible for remote connection
并使 182.73.151.36 mysql 有资格进行远程连接
After that change your connection line and run this program
之后更改您的连接线并运行此程序
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection("jdbc:mysql://182.73.151.36:3306/sbtsystem","sbtuser","Pm@dmin");
回答by JBourne
You need to first download the jdbc driver files for mysql (download from here)
需要先下载mysql的jdbc驱动文件 (从这里下载)
回答by Kashif Nazar
The code looks fine. You need to check the network configurations. Try the following commands to see if the server is accessible.
代码看起来不错。您需要检查网络配置。尝试以下命令以查看服务器是否可访问。
ping 182.73.151.36
telnet 182.73.151.36 3306
平 182.73.151.36
远程登录 182.73.151.36 3306
回答by ali4j
supposing your network configuration is correct, I guess your mysql server on 182.73.151.36 is not configured for remote connection,
假设你的网络配置正确,我猜你182.73.151.36上的mysql服务器没有配置远程连接,