Glassfish 3连接池抛出java.sql.SQLSyntaxErrorException:ORA-00933

时间:2015-06-25 13:17:49

标签: java oracle glassfish glassfish-3 ojdbc

Iam使用Glassfish 3服务器运行Web服务。 连接池在服务器中实现,并且能够ping数据库。

从服务器收到连接,但在运行PreparedStatement时抛出java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended异常。

  

Glassfish 4不会抛出任何异常

查询来自属性文件

QUERY=select * from TABLE where SYSTEMID=?1

使用两个单独的java类来接收连接和进一步处理

  

JDBCUtil.java

public static Connection connectionFromConnectionPool()
        throws NamingException, SQLException {
    Context initCtx = new InitialContext();
    DataSource dataSource = (DataSource) initCtx.lookup(PropertyFileReader
                            .getPropertyValue("connectionPool.JNDI.name"));
    Connection connection = (Connection) dataSource.getConnection();
    if (connection != null) {
        logger.info("Received Connection");
    } else {
        logger.info("No Connection Received");
    }

    return connection;
}
  

DAO.java

ResultSet resultSet = null;
    PreparedStatement preparedStatement = null;
    Connection connection = null;
    try {
        connection = JDBCUtil.connectionFromConnectionPool();

        if (connection != null) {
            preparedStatement = connection
                    .prepareStatement(PropertyFileReader
                            .getPropertyValue("QUERY"));
            if (preparedStatement != null) {
                preparedStatement.setString(1, "systemID");
                resultSet = preparedStatement.executeQuery();     // line No:56

生成日志:

18:13:35,328 INFO - *****.JDBCUtil.connectionFromConnectionPool(JDBCUtil.java:38) - Received Connection
18:13:35,397ERROR - *****(DAO.java:81) - **************************** :: 
java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
at oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:863)
at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1153)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1275)
at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3620)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
at com.sun.gjc.spi.jdbc40.PreparedStatementWrapper40.executeQuery(PreparedStatementWrapper40.java:642)
at *************************************(DAO.java:56)
....................
放置在 glassfish3 \ glassfish \ lib glassfish4 \ glassfish \ lib

中的

ojdbc6.jar

1 个答案:

答案 0 :(得分:0)

检查服务器文件夹中是否还有其他 ojdbc jar,特别是在您正在使用的域文件夹中。

如果服务器文件夹中有不同的jar或不同版本的jar,则可能会导致此类错误。

例如: glassfish3 \ glassfish \ domains \ domain1 \ lib ...

如果有不同版本的jar文件,请将它们全部替换为相同版本。

我使用Glassfish4。我只在 glassfish4 \ glassfish \ lib 中保留了ojdbc jar,这对我来说很好。