hibernate调用存储过程。连接问题

。。。很闷。

现在有个部分需要经常调用存储过程然后访问sqlserver数据库存储过程。

公司用的是hibernate。连接池是用的c3po。

org.hibernate.connection.C3P0ConnectionProvider
20
2
50000
100
3000
2
false
这是配置文件

public PreCallout getcalloutrecord(){
PreCallout pc=new PreCallout();
String sql="{call dt_getcalloutrecord}";
Connection conn=null;
CallableStatement cst=null;
ResultSet rs=null;

    try {
        conn=getSession().connection();
        conn.setAutoCommit(true);
        cst=conn.prepareCall(sql);
        rs=cst.executeQuery();
        if(rs.next()){
            pc.setCallee(rs.getString("callee"));
            pc.setCid(rs.getInt("cid"));
            pc.setCaller(rs.getString("caller"));
        }

    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
        pc.setCid(-1);
        return pc;
    }

    return pc;
}

这是调用存储过程的方法。

现在是这样一个问题。执行多次以后是为什么会执行很慢?

如果您说是连接没关。请问到底关哪些?详细点?

我试过finally{ rs关闭,cst关闭,conn关闭}。。

到底需要关闭吗。不是连接池吗。。

反正我是头大了。。关也慢。不关也慢。。

头大啊。。还有是这样慢的。。慢到执行成功一次。然后继续刷新就很快。

重新开启浏览器的话。又很慢很慢。。help!

[b]问题补充:[/b]
慢的原因原来是其他表的事务将表锁住了。
。。
关了也一样慢。
我写了啊。昏!

我把你的程序改了一下,我也试过用这种方法调用存储过程
public PreCallout getcalloutrecord(){
PreCallout pc=new PreCallout();
String sql="{call dt_getcalloutrecord}";
Connection conn=null;
CallableStatement cst=null;
ResultSet rs=null;

try {
[color=red]Session session=getSession();
conn=session.connection(); [/color]
conn.setAutoCommit(true);
cst=conn.prepareCall(sql);
rs=cst.executeQuery();
if(rs.next()){
pc.setCallee(rs.getString("callee"));
pc.setCid(rs.getInt("cid"));
pc.setCaller(rs.getString("caller"));
}

} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
pc.setCid(-1);
return pc;
} finally{
[color=red] rs.close();
pc.close();
session.close();[/color]
}
return pc;
}

红色部分为我改的,rs和pc是一定要关的,如果你的程序是web应该,你先搞清楚这个web是用什么框架来管理session,如果用ThreadLoad机制在Filter上关,session是不用关的.(就是上面 session.close()这个不要)
还要你可以打印一下操作时间,看一下是访问数据库的时候慢,还是返回的数据太多倒至的慢