数据库输出到java界面,接收并显示某列的和
我想写一个关于记录收入开支的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){}
}
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){}
}
...全文
相关推荐
JAVA串口助手接收数据并解析数据存入MySQL数据库中
JAVA串口助手接收串口来的数据,并将数据解析存储入MySQL数据库中,在使用前串口需要有设备,同时自己创建数据库与数据表,见README
Java JDBC学生数据管理系统
这是一个基于Java的数据库查询系统,可以通过可视化实现对表中数据的增删改查,完成对学生数据信息的管理
idea中database不显示问题的解决
主要介绍了idea中database不显示问题的解决,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧
java实现本地读取图片存储到数据库中并在html网页显示
本地图片使用二进制流存储到MySQL中,然后响应前端的传参,查询后可以显示在HEML网页中,相当于图片的简单上传和显示
编写字符界面的Java Application 接收用户输入的一个字符,并把该字符打印在屏幕上:
编写字符界面的Java Application 接收用户输入的一个字符,并把该字符打印在屏幕上: 源代码如下:import java.io.*; public class SimpleCharInOut { public static void main(String args[]) {char ch=' ' ; System.out.print("Enter a character please:"); try{ ch=(char)System.in.read(); }catch(IOException e){}; System.out.println("You've entered character:"+ch); } }


Java SE
