2017-05-07 53 views
0

嘗試運行符合jdbc6依賴關係的grails 3應用程序。我試圖在我的groovy服務中導入下面的庫,它應該連接到Oracle數據庫來調用存儲過程。Grails 3無法解析類oracle.sql

import oracle.sql.ARRAY 
import oracle.sql.ArrayDescriptor 
import oracle.jdbc.OracleCallableStatement 
import java.sql.Connection 
import groovy.sql.Sql 

import org.apache.poi.ss.usermodel.Workbook 
import org.apache.poi.ss.usermodel.WorkbookFactory 
import org.apache.poi.ss.usermodel.Sheet 
import org.apache.poi.ss.usermodel.Cell 
import org.apache.poi.ss.usermodel.Row 
import org.apache.poi.ss.usermodel.DataFormatter 
import com.wwt.itemuploadapi.rectypes.Rectype 

import java.sql.SQLException 

class ExcelService { 

def dataSource 

private static final FILE_HEADERS = [ 
     'First Name': 'firstName', 
     'Last Name': 'lastName' 
] 

def callApi(List<Rectype> rectype) { 

    OracleCallableStatement callableStmt = null 

    try { 
     def conn = dataSource.getConnection() 
     ArrayDescriptor descriptor = ArrayDescriptor.createDescriptor("TBLTYPE", conn.unwrap(oracle.jdbc.OracleConnection.class)) 
     ARRAY dataElementsArray = new ARRAY(descriptor, conn.unwrap(oracle.jdbc.OracleConnection.class), (Object[])rectype.toArray()) 
     Map map = conn.getTypeMap() 
     map.put("REC_TYPE", Rectype.class) 
     callableStmt = (OracleCallableStatement)conn.prepareCall("{call package.procedure_name(?)}") 
     callableStmt.setArray(1, dataElementsArray); 

     callableStmt.execute() 
    } 
    catch (SQLException ex) { 
     println(ex) 
    } 
} 

啓動時出現以下三個錯誤。但我有我的Gradle: com.oracle:ojdbc6:11.2.0.3圖書館的這些類。所以我不確定它爲什麼不能識別它們。

`unable to resolve class oracle.sql.ARRAY` 
`unable to resolve class oracle.sql.ArrayDescriptor` 
`unable to resolve class oracle.jdbc.OracleCallableStatement` 

任何建議爲什麼這些類無法找到?

回答

0
oracle.jdbc.OracleCallableStatement 

對於您正在使用的ojdbc依賴項版本而言,不再是正確的類。

應該更新到該進口和類:

import java.sql.CallableStatement 
CallableStatement callableStmt = null 

這裏是一個鏈接,會告訴你,你需要做的,替換正在嘗試使用其他過時的類(oracle.sql.ARRAYoracle.sql.ArrayDescriptor)什麼: https://docs.oracle.com/database/121/JAJDB/deprecated-list.html#class

相關問題