当前位置: 技术问答>java相关
mysql & JDBC 问题--(在线等待)
来源: 互联网 发布时间:2015-08-26
本文导语: 以下代码,运行时出错。 con = DriverManager.getConnection( "jdbc:mysql://192.168.54.80:3306/mysql?ser=root&password=qwerty"); ------------------ Exception in thread "main" java.lang.ExceptionInInitializerError: java.lang.Stri ngI...
以下代码,运行时出错。
con = DriverManager.getConnection(
"jdbc:mysql://192.168.54.80:3306/mysql?ser=root&password=qwerty");
------------------
Exception in thread "main" java.lang.ExceptionInInitializerError: java.lang.Stri
ngIndexOutOfBoundsException: String index out of range: 191
at java.lang.String.charAt(String.java:511)
at com.mysql.jdbc.StringUtils.(StringUtils.java:37)
at com.mysql.jdbc.ResultSet.getString(ResultSet.java:2202)
at com.mysql.jdbc.Connection.connectionInit(Connection.java:1083)
at com.mysql.jdbc.Driver.connect(Driver.java:297)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:194)
at data.main(data.java:23)
Press any key to continue...
但如果我将IP地址换成localhost 后就可以正常执行。
问题是我现在想在别的机器上运行呀,怎么办?
con = DriverManager.getConnection(
"jdbc:mysql://192.168.54.80:3306/mysql?ser=root&password=qwerty");
------------------
Exception in thread "main" java.lang.ExceptionInInitializerError: java.lang.Stri
ngIndexOutOfBoundsException: String index out of range: 191
at java.lang.String.charAt(String.java:511)
at com.mysql.jdbc.StringUtils.(StringUtils.java:37)
at com.mysql.jdbc.ResultSet.getString(ResultSet.java:2202)
at com.mysql.jdbc.Connection.connectionInit(Connection.java:1083)
at com.mysql.jdbc.Driver.connect(Driver.java:297)
at java.sql.DriverManager.getConnection(DriverManager.java:512)
at java.sql.DriverManager.getConnection(DriverManager.java:194)
at data.main(data.java:23)
Press any key to continue...
但如果我将IP地址换成localhost 后就可以正常执行。
问题是我现在想在别的机器上运行呀,怎么办?
|
Hi, I guess you maybe using the mm myysql jdbc driver 2.0.8 (or below) , try the mm latest driver ver 2.0.10. Or try mysql offical jdbc driver named Connector/J
http://www.mysql.com/downloads/api-jdbc-stable.html
hope help.
http://www.mysql.com/downloads/api-jdbc-stable.html
hope help.