开发者

Java application fails to connect to mysql as non-root user in debian

开发者 https://www.devze.com 2023-03-11 15:44 出处:网络
Please refer to Stumped SQL Exception for JDBC I have a similar error (listed below) when run as a non-root debian user. But this error does not occur if the java application is run as a root user in

Please refer to Stumped SQL Exception for JDBC

I have a similar error (listed below) when run as a non-root debian user. But this error does not occur if the java application is run as a root user in debian.

The application is configured to connect to mysql as a root user.

I rebooted the system after adding the following entries in my.cnf as advised in the referred question. 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(My开发者_开发百科sqlIO.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 --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). 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)
0

精彩评论

暂无评论...
验证码 换一张
取 消