use pubs
GOCreate Procedure getName
@au_id varchar(15),
@au_name varchar(50) output
as
select @au_name = isnull(au_fname, '') + isnull(au_lname, '')
from authors 
where au_id = @au_id以上是Stored Procedure的代码
============================================================
CallProc.java的代码:import java.sql.*;public class CallProc{
public static void main(String[] args){
     try{
     //加载驱动    
     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     String url="jdbc:odbc:myODBC"; 
     String user="sa";
     String password="";
     //连接数据库
     Connection conn= DriverManager.getConnection(url,user,password); 
    
     CallableStatement call = conn.prepareCall("{call getName(?, ?)}");
     //注册output参数
     call.registerOutParameter(2,java.sql.Types.VARCHAR, 50);
    
     call.setString(1, "172-32-1176");
     call.execute();
     String au_name = call.getString(2);
     conn.close();
     System.out.println(au_name);     }catch(SQLException e){
     e.printStackTrace();
     }catch(ClassNotFoundException e){
     e.printStackTrace();
     }
    }
}
===========================================================
1.建Stored Procedure
2.建一个名为:myODBC的数据源(ODBC数据源)
3.myODBC用的是pubs数据库中的authors表