Glassfish 3 Connection Pool throws java.sql.SQLSyntaxErrorException: ORA-00933

139 views Asked by At

Iam Using Glassfish 3 server to run a web service. Connection Pool is implemented in the server and able to ping Database.

Connection is received from the server but it is throwing java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended exception while running PreparedStatement.

Glassfish 4 does not throw any exception

The Query is taken from property file

QUERY=select * from TABLE where SYSTEMID=?1

Using two seperate java classes for receiving connection and further processing

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

Log generated :

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)
....................

ojdbc6.jar placed in glassfish3\glassfish\lib and glassfish4\glassfish\lib

1

There are 1 answers

1
Venkatesh On BEST ANSWER

Check if there is any other ojdbc jar inside server folder especially inside domain folder you are using.

If there are different jars or different versions of jar in the server folder, it may cause such errors.

For ex : glassfish3\glassfish\domains\domain1\lib...

If there are jar files of different versions, replace them all with same version.

I use Glassfish4. I kept the ojdbc jar only in glassfish4\glassfish\lib which works fine for me.