急救急救!我在myeclipse中连接数据库是老是报Communications link failure due to underlying exception:
Class.forName("com.mysql.jdbc.Driver");conn=DriverManager.getConnection("jdbc:mysql:/...
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/testuseUnicode=true&characterEncoding=utf8","root","1234");
报以下错误
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.SocketException
MESSAGE: java.net.ConnectException: Connection refused: connect
STACKTRACE:
java.net.SocketException: java.net.ConnectException: Connection refused: connect
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:151)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:280)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1765)
at com.mysql.jdbc.Connection.<init>(Connection.java:430)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:268)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at util.DBUtil.getConnection(DBUtil.java:13)
at util.DBUtil.main(DBUtil.java:37)
** END NESTED EXCEPTION **
-----conn-----------null
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1830)
at com.mysql.jdbc.Connection.<init>(Connection.java:430)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:268)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at util.DBUtil.getConnection(DBUtil.java:13)
at util.DBUtil.main(DBUtil.java:37) 展开
conn = DriverManager.getConnection ("jdbc:mysql://localhost:3306/testuseUnicode=true&characterEncoding=utf8","root","1234");
报以下错误
com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:
** BEGIN NESTED EXCEPTION **
java.net.SocketException
MESSAGE: java.net.ConnectException: Connection refused: connect
STACKTRACE:
java.net.SocketException: java.net.ConnectException: Connection refused: connect
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:151)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:280)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1765)
at com.mysql.jdbc.Connection.<init>(Connection.java:430)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:268)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at util.DBUtil.getConnection(DBUtil.java:13)
at util.DBUtil.main(DBUtil.java:37)
** END NESTED EXCEPTION **
-----conn-----------null
at com.mysql.jdbc.Connection.createNewIO(Connection.java:1830)
at com.mysql.jdbc.Connection.<init>(Connection.java:430)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:268)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at util.DBUtil.getConnection(DBUtil.java:13)
at util.DBUtil.main(DBUtil.java:37) 展开
3个回答
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
暂时发现了一个错误:
("jdbc:mysql://localhost:3306/testuseUnicode=true&characterEncoding=utf8","root","1234");
少个问号——>
("jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8","root","1234");
("jdbc:mysql://localhost:3306/testuseUnicode=true&characterEncoding=utf8","root","1234");
少个问号——>
("jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8","root","1234");
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你确定你数据库的服务开了吗?
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询