最近參與了使用JAVA語言開發的項目,開發環境是MyEclipse + WebLogic。
自己也發了幾個文章介紹了一下使用到的一些技術。
如何在JAVA程式中使用Struct一次傳入多條資料給Oracle的預存程序。
如何以Collection變數作為資料來源來向資料表中插入資料,或者更新資料。
如何在Oracle中修改Collection類型的變數。
如何在Oracle中向Collection類型的變數中逐條插入資料。
但是在進行UT的時候下面的代碼無法通過。
StructDescriptor st = new StructDescriptor("DEPARTMENT_TYPE",dbConn);
出現的錯誤是:
Caused by: java.rmi.MarshalException: error marshalling return; nested exception is:
java.io.NotSerializableException: oracle.jdbc.driver.T4CConnection
at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:195)
出現這樣問題的原因都是有對象沒有進行序列化。我們出現這個問題的現象是:進行UT時程式無法運行,但是從JSP頁面進行調用就沒有問題。所以分析的結果是我們寫的項目架構中用於UT的部分沒有繼承序列化或者Struct本身沒有繼承序列化。
參考:
http://forums.bea.com/thread.jspa?messageID=600034901&tstart=0
http://forums.bea.com/thread.jspa?messageID=400006195
http://e-docs.bea.com/wls/docs81/jdbc/thirdparty.html#1043705
http://e-docs.bea.com/wls/docs81/jdbc/programming.html#1054307
//******************************************************************************************
To obtain a connection for a JDBC client, use a Java Naming and Directory Interface (JDNI) lookup to locate the DataSource object, as shown in the following code fragment.
Note: When using a JDBC connection in a client-side application, the exact same JDBC driver classes must be in the CLASSPATH on both the server and the client. If the driver classes do not match, you may see java.rmi.UnmarshalException exceptions.
//******************************************************************************************