jdbc存储过程示例
2017-01-12 19:58
211 查看
create or replace procedure getNewsCount(v_totalCount out number) is
begin
SELECT COUNT(*) INTO v_totalCount FROM news_detail;
end getNewsCount;
//获取新闻总数(执行存储过程)
public int getTotalCountProc(){
int totalCount=0;
CallableStatement proc=null;
String sql="{call getNewsCount(?)}";
getConnection();
try {
proc=conn.prepareCall(sql);
proc.registerOutParameter(1, Types.INTEGER);
proc.execute();
totalCount=proc.getInt(1);
} catch (SQLException e) {
e.printStackTrace();
}finally{
if(proc!=null)
try {
proc.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return totalCount;
}
begin
SELECT COUNT(*) INTO v_totalCount FROM news_detail;
end getNewsCount;
//获取新闻总数(执行存储过程)
public int getTotalCountProc(){
int totalCount=0;
CallableStatement proc=null;
String sql="{call getNewsCount(?)}";
getConnection();
try {
proc=conn.prepareCall(sql);
proc.registerOutParameter(1, Types.INTEGER);
proc.execute();
totalCount=proc.getInt(1);
} catch (SQLException e) {
e.printStackTrace();
}finally{
if(proc!=null)
try {
proc.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return totalCount;
}
相关文章推荐
- 一个示例存储过程
- 通过JDBC创建Oracle的存储过程
- 有限层树形数据转换成无限层树形数据的示例存储过程(MS SQL 2K)
- SQL Server存储过程和参数示例
- SQL Server存储过程和参数示例
- ASP调用SqlServer存储过程的经典示例(原创)
- 微軟隱藏的SQL Server存储过程和参数示例(轉載)
- JDBC里取得Oracle存储过程动态结果集
- [源代码]千万级数据分页存储过程示例!
- 在SQL Server 2000中insert的时候返回自动编号的id 存储过程示例[原]
- [源代码]千万级数据分页存储过程示例!
- 存储过程示例:
- 一个分页的类,分页的存储过程,分页的jsp示例
- 存储过程示例
- 几篇关于在.Net中调用存储过程的示例文章
- JDBC执行存储过程得到多结果集
- [导入][源代码]千万级数据分页存储过程示例!
- 存储过程示例
- SQL Server存储过程和参数示例
- [导入]在SQL Server 2000中insert的时候返回自动编号的id 存储过程示例[原]