oracle SQL state [99999]; error code [17026]; 數字溢出

來源:互聯網
上載者:User

標籤:oracle   數字溢出   

org.springframework.jdbc.UncategorizedSQLException: CallableStatementCallback; uncategorized SQLException for SQL [{call updateUser(?, ?, ?, ?, ?, ?)}]; SQL state [99999]; error code [17026]; 數字溢出;   

產生背景:
oracle資料庫從11g升級到12c調用預存程序的代碼是用的spring的StoredProcedure程式中有設定預存程序參數類型 new SqlOutParameter("userId",Types. INTEGER)
create or replace procedure updateUser(userId in int ....) as...
在執行的時候,資料庫驅動將傳的參數類型和存數過程參數進行轉換,報這個錯。

原因:我用的舊版本spring的StoredProcedure可能是有個bug        他將你傳的參數類型給變了,最後不是integer轉int,是long轉int,這樣12c的驅動在轉的時候就會報錯。
        解決方案:方法一、把 Types. INTEGER換成Types. NUMERIC       這樣可能12c上解決了,不知道兼不相容低版本了,沒試過。
方法二、換調存數過程的寫法
                jt.execute( new ConnectionCallback(){
                     public Object doInConnection(Connection connection)  throws SQLException, DataAccessException {                        CallableStatement st =  null;                        st=connection.prepareCall("{call updateUser(?,?,?,?,?)}");                        st.registerOutParameter(1,Types. INTEGER);                        st.registerOutParameter(4,Types. INTEGER);                        st.registerOutParameter(5,Types. VARCHAR);                        st.setInt(1,0);                        st.setInt(2,insID);                        st.setInt(3,1);                        st.setInt(4,1);                        st.setString(5,"OK");                        st.execute();                        CodeName c =  new CodeName();                        c.setCode("" + st.getInt(4));                        c.setName(st.getString(5));                         return c;                    }                });

oracle SQL state [99999]; error code [17026]; 數字溢出

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.