2017-02-02 169 views
0

執行DB_ID SQL函數我想調用的SQL Server DB_ID函數來獲取從階用戶數據庫的databaseID ..從斯卡拉

Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver") 
     val connection: Connection = DriverManager.getConnection(jdbcConnectionString) 
    //SELECT database_id FROM sys.databases WHERE Name 
    val statement: CallableStatement = connection.prepareCall("{? =call DB_ID(?)}") 
    statement.registerOutParameter(1,java.sql.Types.INTEGER) 
    statement.setString(2,s"'ABC_STORE'") 
    statement.execute() 
    val a = statement.getInt(1) 

我得到一個錯誤COULD NOT FIND the stored procedure DB_ID

我如何得到這個工作。

回答