java Oracle存储过程在linux上运行失败,可在windows上运行
我已将程序声明为:
PROCEDURE procName(id in number, string1 in varchar2, string2 in varchar2, userId in number, updateAll in number, out_ret out varchar2);
当我试图在windows或SQL Developer上执行此过程时,它可以完美地工作。 当在linux机器(centOs 7.1)上运行相同的jar时,问题出现了:oracle抛出了一个异常:
java.sql.SQLException: ORA-01403: no data found
ORA-01403: no data found
ORA-06512: at 'foo', line 15
ORA-04088: error during execution of trigger 'bar'
...
代码如下:
public static Boolean callTest(long id, String string1,
String string2, long employeeId) {
Connection conn = null;
CallableStatement callableStatement = null;
Boolean ret = true;
try {
conn = getDBConnection();
conn.setAutoCommit(false);
callableStatement = conn.prepareCall("{ CALL proc_name(?,?,?,?,?,?) }");
callableStatement.setLong(1, id);
callableStatement.setString(2, string1);
callableStatement.setString(3, string2);
callableStatement.setLong(4, employeeId);
callableStatement.setBoolean(5, true);
callableStatement.registerOutParameter(6, java.sql.Types.VARCHAR);
callableStatement.execute();
String out = callableStatement.getString(6);
log.info("Procedure returned:" + out);
conn.rollback();
} catch (SQLException e) {
log.info("Procedure exception:" + e.getLocalizedMessage());
} finally {
if (callableStatement != null) {
try {
callableStatement.close();
} catch (SQLException e) {
log.info("Error trying to close statement:" + e.getLocalizedMessage());
}
}
if (conn != null) {
try {
conn.close();
} catch (SQLException e) {
log.info("Error trying to close connection:" + e.getLocalizedMessage());
}
}
}
return ret;
}
private static Connection getDBConnection() {
Connection dbConnection = null;
try {
Class.forName("net.sf.log4jdbc.DriverSpy");
dbConnection = DriverManager.getConnection(
DB_CONNECTION, DB_USER,
DB_PASSWORD);
} catch (SQLException e) {
log.info("error creating connection" + e.getLocalizedMessage());
} catch (ClassNotFoundException e) {
log.info("error creating connection" + e.getLocalizedMessage());
}
return dbConnection;
}
调用的参数是相同的。
这个问题的原因是什么
@编辑1
Jar是在windows上创建的,然后在windows和linux上运行,所以两个系统的DB url、用户和密码都是相同的。
@编辑2
我不能给出任何程序或触发代码,我没有
# 1 楼答案
谢谢你AlexPoole,
你的猜测是对的, 该过程获取客户端用户名,
并在数据库中查找它。 不幸的是,windows和linux上的系统用户不同