gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 13:43:52 24 4
gpt4 key购买 nike

我使用 Glassfish 3 服务器来运行 Web 服务。连接池是在服务器中实现的,能够ping通数据库。

从服务器收到连接,但在运行PreparedStatement时抛出java.sql.SQLSyntaxErrorException:ORA-00933:SQL命令未正确结束异常。

Glassfish 4 does not throw any exception

查询取自属性文件

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

ojdbc6.jar放置在glassfish3\glassfish\libglassfish4\glassfish\lib

最佳答案

检查服务器文件夹内是否有任何其他ojdbc jar,尤其是您正在使用的域文件夹内。

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

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

如果存在不同版本的jar文件,请全部替换为相同版本。

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

关于java - Glassfish 3 连接池抛出 java.sql.SQLSyntaxErrorException : ORA-00933,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31051510/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com