我想写一个关于记录收入开支的SQL数据库程序,用java打开界面,现在不知道如何用a接收金额一列的和,请求帮忙。
PreparedStatement ps=null;
Connection ct=null;
ResultSet rs=null;
int a=0;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
ct=DriverManager.getConnection("jdbc:odbc:sql server","sa","56482913tj");
ps=ct.prepareStatement("select sum(distinct jine) from ShouRu");
rs=ps.executeQuery();
xxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx
}catch(Exception e){}
finally{
try{
if(rs!=null){
rs.close();
}
if(ps!=null){
ps.close();
}
if(ct!=null){
ct.close();
}
}catch(Exception e){}
}