getsurnamesarray.java~2~

来自「连接oracle的java库」· JAVA~2~ 代码 · 共 41 行

JAVA~2~
41
字号
package com.zp.callProcFunc;
//call a database function to return an array of surnames
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.CallableStatement;
import oracle.jdbc.OracleTypes;
public class GetSurnamesArray
{
  public GetSurnamesArray()
  {
  }
public static void GetSurnames()
  {
    Connection connection=null;
    String url="jdbc:oracle:thin:@901-32:1521:xianmap";
    try
    {
      Class.forName("oracle.jdbc.OracleDriver");
      connection =DriverManager.getConnection(url,"userstoremap2","Icando41") ;
    }catch(java.lang.ClassNotFoundException  noclasse)
    {
      System.out.println("get a "+noclasse.getClass() +"\nwith message "+noclasse.getMessage() ) ;
      System.exit(-1) ;
    }catch(java.sql.SQLException sqle)
    {
      System.out.println("get a "+sqle.getClass() +"\nwith message "+sqle.getMessage() ) ;
      System.exit(-1) ;
    }
    try
    {
      CallableStatement callFunc = connection.prepareCall(
          "{?=call get_all_surnames()}");
      //register the out parameter
      callFunc.registerOutParameter(1,OracleTypes.ARRAY ,"ARRAY_OF_SURNAME");
    }catch(java.sql.SQLException  sqle)
    {
      System.out.println("get a "+sqle.getClass() +"\nwith message "+sqle.getMessage() ) ;
      System.exit(-1) ;
    }
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?