Com.mysql.exceptions_CentOS服务器中的com.mysql.jdbc.exceptions.MySQLSyntaxErrorException异常
发布日期:2021-10-26 17:40:22 浏览次数:5 分类:技术文章

本文共 2041 字,大约阅读时间需要 6 分钟。

在CentOS服务器上运行一个java代码来连接mysql

我的代码是 -

String server = "", url = "", password = "", user = "", databasename = "";

Connection con = null;

try {

server = "xxx.xxx.xxx.xxx";

databasename = "xx";

user = "user";

password = "pass";

Class.forName("com.mysql.jdbc.Driver");

url = "jdbc:mysql://" + server + "/" + databasename + "";

con = DriverManager.getConnection(url, user, password);

System.out.println(server + " Database connection established");

System.out.println(con);

} catch (Exception e) {

System.out.println("***************connection failed********************");

e.printStackTrace();

}我的数据库运行在同一台服务器上。

我在我的本地系统和其他服务器上运行这个代码以获得相同的数据库,并且它的运行正常,但是它不在我的数据库可用的相同服务器上运行。

我得到这个例外 -

com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '??????????????' at line 1

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1027)

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3361)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3295)

at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1852)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1975)

at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2470)

at com.mysql.jdbc.ConnectionImpl.configureClientCharacterSet(ConnectionImpl.java:1669)

at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3336)

at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1979)

at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:718)

at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:287)

at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:283)

at java.sql.DriverManager.getConnection(libgcj.so.10)

at java.sql.DriverManager.getConnection(libgcj.so.10)

at testthread.ConnectionFactory.getConnection(ConnectionFactory.java:28)

at testthread.ConnectionFactory.main(ConnectionFactory.java:39)是任何一个帮助我什么问题。

转载地址:https://blog.csdn.net/weixin_33952775/article/details/113380591 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:mysql case break_MySQL全面瓦解20:可编程性之流程控制语句
下一篇:基于DNS的mysql高可用_【MySQL】DNS与MHA/ZABBIX构建的高可用MySQL

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年03月23日 12时52分39秒