« | August 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | | | | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | | | | | | | |
| 公告 |
暂无公告... |
Blog信息 |
blog名称: 日志总数:42 评论数量:31 留言数量:0 访问次数:178332 建立时间:2007年7月30日 |

| |
[数据库]通过存储过程取数据库信息----sql server 下 原创空间
gareth 发表于 2008/1/24 10:15:19 |
需要spring.jar 下面的方法是取得数据库大小.import java.sql.CallableStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Types;import org.springframework.dao.DataAccessException;import org.springframework.jdbc.core.CallableStatementCallback;import org.springframework.jdbc.core.support.JdbcDaoSupport;public class JdbcDatabaseDao extends JdbcDaoSupport implements DatabaseDao { public String queryDatabaseSize(final String dbname) { final String[] sizeArray = new String[] { null }; getJdbcTemplate().execute("{? = call sp_helpdb(?)}", new CallableStatementCallback() { public Object doInCallableStatement( CallableStatement statemante) throws SQLException, DataAccessException { statemante.registerOutParameter(1, Types.OTHER); statemante.setObject(2, dbname); ResultSet rs = statemante.executeQuery(); if (rs.next()) { sizeArray[0] = rs.getString("db_size"); } return null; } }); return sizeArray[0]; }} |
|
|