在SQL中有函数,比如COUNT(*),怎样通过JDBC调用获得函数值????
HI 问题点数:50、回复次数:4Top
1 楼beyond_xiruo(CorruptionException)回复于 2002-11-20 14:47:21 得分 50
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select count(*) as myCount from class";
ResultSet rs=stmt.executeQuery(sql);
int rcount=0;
if(rs.next())
rcount=rs.getInt(1);
或者
rcount=rs.getInt("myCount");Top
2 楼baitianhai(hong)回复于 2002-11-20 14:51:24 得分 0
String str=newString;
while(rs.next){
str=rs.getString(1)
}Top
3 楼baitianhai(hong)回复于 2002-11-20 14:52:52 得分 0
这要看你象得到什么类型的数据了,就用对应的方法Top
4 楼elle1975(ping)回复于 2002-11-20 17:06:40 得分 0
喔,这样,
THANK YOU ,
BEST REGARDSTop




