[英]Java application fails to connect to mysql as non-root user in debian
Please refer toStumped SQL Exception for JDBC请参阅难倒的 SQL JDBC 异常
I have a similar error (listed below) when run as a non-root debian user.以非 root debian 用户身份运行时,我遇到了类似的错误(如下所列)。 But this error does not occur if the java application is run as a root user in debian.但如果 java 应用程序在 debian 中以 root 用户身份运行,则不会出现此错误。
The application is configured to connect to mysql as a root user.该应用程序配置为以 root 用户身份连接到 mysql。
I rebooted the system after adding the following entries in my.cnf as advised in the referred question.我按照参考问题中的建议在 my.cnf 中添加了以下条目后重新启动了系统。 But the same error occurs.但是会发生同样的错误。
character_set_server=utf8 collation_server=utf8_general_ci
Please help.请帮忙。
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:1026) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536) at com.mysql.jdbc.ConnectionImpl.configureClientCharacterSet(ConnectionImpl.java:1751) at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3425) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2045) at com.mysql.jdbc.ConnectionImpl.(ConnectionImpl.java:718) at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:298) at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282) at java.sql.DriverManager.getConnection(libgcj.so.10) at java.sql.DriverManager.getConnection(libgcj.so.10) at org.apache.commons.dbcp.DriverManagerConnectionFactory.createConnection(DriverManagerConnectionFactory.java:65) at org.apache.commons.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:294) at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:840) at org.apache.commons.dbcp.PoolingDataSource.getConnection(PoolingDataSource.java:96) at edu.amrita.jdbc.connectionpool.bundle.DBConnectionPoolImpl.getConnection(DBConnectionPoolImpl.java:95) at edu.amrita.devicetalk.protocol.aesccmp.DatabaseInterface.getRegisteredDevices(DatabaseInterface.java:116)
Make sure that non-root uses Oracle Java ( sun-java6-jdk
and sun-java6-jre
packages from non-free) using update-alternatives command (as root):使用update-alternatives命令(作为 root)确保非 root 用户使用 Oracle Java(来自非免费的sun-java6-jdk
和sun-java6-jre
包):
# update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/gij-4.4 1044 auto mode
1 /usr/bin/gij-4.4 1044 manual mode
2 /usr/lib/jvm/java-6-sun/jre/bin/java 63 manual mode
Press enter to keep the current choice[*], or type selection number:
Choose appropriate number (here 2).选择适当的数字(此处为 2)。 After that there should be:之后应该有:
$ java -version
java version "1.6.0_24"
Java(TM) SE Runtime Environment (build 1.6.0_24-b07)
Java HotSpot(TM) Client VM (build 19.1-b02, mixed mode, sharing)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.