Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1906178
  • 博文数量: 219
  • 博客积分: 8963
  • 博客等级: 中将
  • 技术积分: 2125
  • 用 户 组: 普通用户
  • 注册时间: 2005-10-19 12:48
个人简介

文章分类

全部博文(219)

文章存档

2021年(1)

2020年(3)

2015年(4)

2014年(5)

2012年(7)

2011年(37)

2010年(40)

2009年(22)

2008年(17)

2007年(48)

2006年(31)

2005年(4)

分类: Java

2011-02-25 09:48:39

以下是调用方法,测试代码没贴.

public class ProcedureTest
{
    public Connection getConnection() throws Exception
    {
        try
        {
            Class.forName("com.mysql.jdbc.Driver");
            Connection connection = DriverManager.getConnection(
                    "jdbc:mysql://localhost:3306/mas2?autoReconnect=true&useUnicode=true&characterEncoding=utf8",
                    "root", "canada");
            return connection;
        }
        catch (Exception e)
        {
            throw e;
        }
    }

    public ResultSet callProcedure() throws Exception
    {
        Connection connection = getConnection();
        CallableStatement statement = connection.prepareCall("{call proc_masbiz_event(?, ?, ?, ?)}");
        statement.setInt(1, 1);
        statement.setString(2, "2010-04-01");
        statement.setString(3, "2010-04-30");
        statement.setInt(4, 1);
        ResultSet rs = statement.executeQuery();
        return rs;
    }
}


阅读(1022) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~