0
我已經程序聲明: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時:甲骨文拋出異常:
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;
}
調用的參數是相同的。
這個問題的原因是什麼?
@Edit 1個
罐在Windows上創建,然後在Windows和Linux上運行,所以數據庫的URL,用戶名和密碼是這兩個系統是相同的。
@Edit 2 我不能給任何程序,或觸發代碼,我沒有它。
您正在收到的錯誤表明您正在執行的選擇無返回行,這很可能源於操作系統的差異。更有可能您正在訪問每個環境中的不同數據庫,並且表中的數據不相同。 –
爲了防止基於客戶端環境進行某些操作,您是否可以添加觸發器「代碼」的代碼? (我可以想象一個歷史觸發器獲取當前osuser並在某處查找它;例如,一個不同的操作系統帳戶可能會導致一個錯誤,但純粹的猜測!) –
那麼異常是由觸發器引發的,所以你會需要詢問能夠看到該代碼的人(假設你不能在'all_sources'中看到它)。我們無法幫助我們看不到的東西* 8-) –