个人帐目管理系统java_Java 项目 个人帐目管理系统
目錄
第一部分項目描述 3
1.1項目目的 3
第二部分需求和開發環境 3
2.1使用技術和開發環境 3
2.2項目需求 3
2.3詳細功能 3
2.4 E-R圖 3
2.5數據庫的設計 3
2.5.1數據表的設計 3
2.5.2數據庫約束的設計 4
2.5.3數據庫序列的設計 4
2.5.4數據庫索引的設計 4
2.5.5數據庫視圖的設計 5
2.5.6數據庫觸發器的設計 5
2.5.7數據庫函數的設計 5
2.5.8數據庫存儲過程的設計 6
2.6業務層設計 6
2.6.1 xx業務 6
2.6.2 xx業務 6
2.6.3 xx業務 6
2.7展示層(界面)設計
6
2.7.1 xx界面 7
2.7.2 xx界面 7
2.7.3 xx界面 7
第三部分項目總結 7
第一部分項目描述
1.1項目目的
開發一個賬目明細管理軟件,用于記錄和查詢個人的賬目情況,記錄的內容包括:賬目類型(支出/收入)、賬目金額、記錄日期(日期格式為:yyyy-MM-dd)和備注信息。
第二部分需求和開發環境
2.1使用技術和開發環境
Oracle11g
2.2項目需求
教學質量是學校生存與發展的生命線,不斷提高課堂教學水平是學校和每一位教師的共同心愿。及時了解課堂教學的主體—學生對教學情況的評價及建議,有利于教師發現自己教學中的優點以及不足,從而進一步改進教學方法,提高教學水平。為了更好的提高教學水平,建立學校與學員的更好勾通,院領導研究決定研發本系統,并提供考核內容管理、反饋項目管理、反饋表管理、數據統計分析等主要功能,本階段案例主要以考核內容管理為主要分析目標。
2.3詳細功能
1、添加賬目
添加賬目時,首先,系統自動生成一個賬目流水編號,如果為第一條賬目記錄,則編號為預設值“1”;如果不是第一條記錄,則獲取最后一條賬目記錄,取出編號并加一,即為新賬目記錄編號。然后需要用戶輸入賬目信息,包括賬目類型、金額、日期和備注,其中日期為系統自動生成,完成后賬目信息被保存到一個文件中,并反饋給用戶一條賬目信息。
2、修改賬目
賬目記錄修改功能描述:首先,提示用戶輸入要修改的賬目記錄編號,并進行有效性驗證。然后顯示此筆賬目記錄詳細信息,提示修改(日期不修改)。修改完成后,將此賬目記錄保存到賬目記錄文件中。
3、刪除賬目
賬目記錄刪除功能描述:首先,提示用戶輸入要修改的賬目記錄編號,并進行有效性驗證。然后顯示此筆賬目記錄詳細信息,提示刪除。待用戶確認后,將此記錄從賬目記錄文件中刪除。
4、查詢賬目
查詢賬目功能包括:查詢單個和查詢全部。
查詢單個賬目信息:首先,提示用戶輸入要修改的賬目記錄編號,并進行有效性驗證。然后顯示此筆賬目記錄詳細信息。
查詢全部賬目信息:顯示全部賬目記錄詳細信息,如果沒有賬目信息,則提示沒有賬目記錄。
2.5數據庫的設計
2.5.1 數據表的設計
表1 個人賬目表
表名
TALLY(個人賬目表)
列名
描述
數據類型
空/非空
約束條件
TID
ID編號
number
非空
主鍵,標識列
TTYPE
類型名稱
Varchar2(20)
非空
MONEY
金錢
Number(4)
非空
DATE
時間
date
默認
REMARK
備注
Varchar2(20)
2.5.3 數據庫序列的設計
功能:TID進行插入自增
實現:CREATE SEQUENCE SEQ_TALLY;
2.5.6數據庫觸發器的設計
功能:當進行插入數據的時候,TID進行自增
實現:CREATE OR REPLACE TRIGGER TRI_TALLY
BEFORE INSERT OR UPDATE ?ON TALLY FOR EACH ROW
BEGIN
select seq_tally.nextval into :New."tid" from dual;
END;
2.6
業務層設計
//數據庫操作
package com.handson.entity;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;
import javax.swing.JOptionPane;
import com.tcl.util.DBcon;
public class DBinsert {
public static void Register(String Itype,String Imoney,String Iremark){
DBcon dBcon=new DBcon();
Connection conn=dBcon.getConn();
if(conn != null){
try {
Statement sm = conn.createStatement();//根據連接獲取一個執行sql語句的對象
int n = sm.executeUpdate("insert into TALLY (TTYPE,MONEY,REMARK) VALUES('"+Itype+"','"+Imoney+"','"+Iremark+"')");
if(n>0){
JOptionPane.showMessageDialog(null, "數據添加成功!");
}
else{
JOptionPane.showMessageDialog(null, "數據添加失敗!");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
//Swing 界面package com.handson.services;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import com.handson.entity.DBinsert;
import com.tcl.util.DBcon;
public class SWinsert extends JFrame{
JTextField type = new JTextField(10);//文本框
JTextField money = new JTextField(10);
JTextField remark = new JTextField(10);
String Itype,Imoney,Iremark;
Box baseBox,boxV1,boxV2;//面板
JButton btn1 = new JButton("OK");
public SWinsert(){
this.setBounds(100,100,310,260);//窗體大小
this.setTitle("ADD");
this.setLayout(new java.awt.FlowLayout());
init();
this.setVisible(true);
this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);//只關閉當前窗口
}
void init(){
boxV1 = Box.createVerticalBox();
boxV1.add(new JLabel("TYPE:"));
boxV1.add(Box.createVerticalStrut(8));
boxV1.add(new JLabel("MONEY:"));
boxV1.add(Box.createVerticalStrut(8));
boxV1.add(new JLabel("REMARK:"));
boxV1.add(Box.createVerticalStrut(8));
boxV2 = Box.createVerticalBox();
boxV2.add(type);
boxV2.add(Box.createVerticalStrut(8));
boxV2.add(money);
boxV2.add(Box.createVerticalStrut(8));
boxV2.add(remark);
boxV2.add(Box.createVerticalStrut(8));
baseBox = Box.createHorizontalBox();
baseBox.add(boxV1);
boxV2.add(Box.createVerticalStrut(10));
baseBox.add(boxV2);
add(baseBox);
add(btn1);
btn1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Itype = type.getText();
Imoney = money.getText();
Iremark = remark.getText();
//判斷是否為空,因為不能插入空數據
if(!Itype.equals("")&&!Imoney.equals("")&&!Iremark.equals(""))
{
try {
Integer.parseInt(Imoney); // 只能為正整數
DBcon dBcon=new DBcon();
Connection con=dBcon.getConn();
if(con==null){
System.out.println("數據庫插入連接失敗");
}
else{
System.out.println("數據庫插入連接成功");
DBinsert.Register(Itype,Imoney,Iremark);
type.setText("");
money.setText("");
remark.setText("");
}
} catch (Exception e2) {
// TODO: handle exception
JOptionPane.showMessageDialog(null, "Money格式不正確,請重新輸入!");
money.setText("");
}
}
else{
JOptionPane.showMessageDialog(null, "數據不能為空,請補充完整!");
}}
});
}
}
2.6.2修改賬目業務
//Swing 界面package com.handson.services;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import com.handson.entity.DBupdate;
import com.tcl.util.DBcon;
public class SWupdate extends JFrame{
JTextField id = new JTextField(10);
JTextField type = new JTextField(10);
JTextField money = new JTextField(10);
JTextField remark = new JTextField(10);
String Uid,Utype,Umoney,Uremark;
Box baseBox,boxV1,boxV2;
JButton btn1 = new JButton("OK");
public SWupdate(){
this.setBounds(100,100,310,260);
this.setTitle("UPDATE");
this.setLayout(new java.awt.FlowLayout());
init();
this.setVisible(true);
this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);//只關閉當前窗口
}
void init(){
boxV1 = Box.createVerticalBox();
boxV1.add(new JLabel("ID:"));
boxV1.add(Box.createVerticalStrut(8));
boxV1.add(new JLabel("TYPE:"));
boxV1.add(Box.createVerticalStrut(8));
boxV1.add(new JLabel("MONEY:"));
boxV1.add(Box.createVerticalStrut(8));
boxV1.add(new JLabel("REMARK:"));
boxV1.add(Box.createVerticalStrut(8));
boxV2 = Box.createVerticalBox();
boxV2.add(id);
boxV2.add(Box.createVerticalStrut(8));
boxV2.add(type);
boxV2.add(Box.createVerticalStrut(8));
boxV2.add(money);
boxV2.add(Box.createVerticalStrut(8));
boxV2.add(remark);
boxV2.add(Box.createVerticalStrut(8));
baseBox = Box.createHorizontalBox();
baseBox.add(boxV1);
boxV2.add(Box.createVerticalStrut(10));
baseBox.add(boxV2);
add(baseBox);
add(btn1);//按鈕
btn1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Uid = id.getText();
Utype = type.getText();
Umoney = money.getText();
Uremark = remark.getText();
if (!Uid.equals("")&&!Utype.equals("")&&!Umoney.equals("")&&!Uremark.equals("")) {
try {
Integer.parseInt(Umoney); // 只能為正整數
DBcon dBcon=new DBcon();
Connection con=dBcon.getConn();
if(con==null){
System.out.println("數據庫更新連接失敗");
}
else{
System.out.println("數據庫更新連接成功");
DBupdate.update(Uid,Utype,Umoney,Uremark);
id.setText("");
type.setText("");
money.setText("");
remark.setText("");
}
} catch (Exception e2) {
// TODO: handle exception
JOptionPane.showMessageDialog(null, "Money格式不正確,請重新輸入!");
money.setText("");
}
}
else {
JOptionPane.showMessageDialog(null, "數據不能為空,請補充完整!");
}
}
});
}
}
數據庫更新操作
package com.handson.entity;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;
import javax.swing.JOptionPane;
import com.tcl.util.DBcon;
public class DBupdate {
public static void update(String Uid,String Utype,String Umoney,String Uremark){
DBcon dBcon=new DBcon();
Connection conn=dBcon.getConn();
if(conn != null){
try {
Statement sm = conn.createStatement();
int n = sm.executeUpdate("update TALLY set TTYPE= '" + Utype+ "',MONEY='"+Umoney+
"',REMARK='" + Uremark+ "'where TID='" + Uid+ "'");
if(n>0){
JOptionPane.showMessageDialog(null, "Update Success!");
}
else{
JOptionPane.showMessageDialog(null, "ID信息不符合,請確認后重新輸入");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
2.6.3刪除賬目業務
Swing 界面
package com.handson.services;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import com.handson.entity.DBdelete;
import com.tcl.util.DBcon;
public class SWdelete extends JFrame{
JTextField id = new JTextField(10);
String Did;
Box baseBox,boxV1,boxV2;//面板
JButton btn1 = new JButton("OK");
public SWdelete(){
this.setBounds(100,100,310,260);
this.setTitle("DELETE");
this.setLayout(new java.awt.FlowLayout());//容器
init();
this.setVisible(true);
this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);//只關閉當前窗口
}
void init(){
boxV1 = Box.createVerticalBox();
boxV1.add(new JLabel("ID:"));
boxV2 = Box.createVerticalBox();
boxV2.add(id);
baseBox = Box.createHorizontalBox();
baseBox.add(boxV1);
boxV2.add(Box.createVerticalStrut(10));
baseBox.add(boxV2);
add(baseBox);//容器
add(btn1);
btn1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Did = id.getText();
if (!id.equals("")) {
try {
Integer.parseInt(Did); // 只能為正整數
DBcon dBcon=new DBcon();
Connection con=dBcon.getConn();
if(con==null){
System.out.println("數據庫刪除連接失敗");
}
else{
System.out.println("數據庫刪除連接成功");
DBdelete.Delete(Did);
id.setText("");
}
} catch (Exception e2) {
// TODO: handle exception
JOptionPane.showMessageDialog(null, "ID格式不正確,請重新輸入!");
}
}
else{
JOptionPane.showMessageDialog(null, "數據不能為空,請補充完整!");
}
}
});
}
}
數據庫刪除操作
package com.handson.entity;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import javax.swing.JOptionPane;
import com.tcl.util.DBcon;
public class DBdelete {
public static void Delete(String Did){
DBcon dBcon=new DBcon();
Connection conn=dBcon.getConn();
if(conn== null){
dBcon.getConn();
}
PreparedStatement sm = null;//PreparedStatement用于使用綁定變量重用執行計劃
try {
String sql = "delete from TALLY where TID = ?";
sm = conn.prepareStatement(sql);
sm.setString(1, Did);//給第一個問號賦值
int n = sm.executeUpdate();
if(n>0){
JOptionPane.showMessageDialog(null, "Delete Success!");
}
else{
JOptionPane.showMessageDialog(null, "請輸入正確的ID!");
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
2.6.4查詢賬目業務
查詢單個賬目信息:
Swing 界面
package com.handson.services;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.Connection;
import javax.swing.Box;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import com.handson.entity.DBselect;
import com.tcl.util.DBcon;
public class SWselect extends JFrame{
JTextField id = new JTextField(10);//要查詢的卡號
JTextField type = new JTextField(10);
JTextField money = new JTextField(10);
JTextField date = new JTextField(10);
JTextField remark = new JTextField(10);
JLabel cxjg = new JLabel();//顯示結果標簽
Box baseBox,boxV1,boxV2;
JButton btn1 = new JButton("查詢");
public SWselect(){
this.setBounds(100,100,310,260);
this.setTitle("查詢賬目");
this.setLayout(new java.awt.FlowLayout());
init();
this.setVisible(true);
this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);//只關閉當前窗口
}
void init(){
boxV1 = Box.createVerticalBox();
boxV1.add(new JLabel("請輸入要查詢的ID:"));
boxV1.add(Box.createVerticalStrut(8));
boxV1.add(new JLabel("結果如下:"));
boxV1.add(Box.createVerticalStrut(8));
boxV1.add(new JLabel("TYPE:"));
boxV1.add(Box.createVerticalStrut(8));
boxV1.add(new JLabel("MONEY:"));
boxV1.add(Box.createVerticalStrut(8));
boxV1.add(new JLabel("DATE:"));
boxV1.add(Box.createVerticalStrut(8));
boxV1.add(new JLabel("REMARK:"));
boxV1.add(Box.createVerticalStrut(8));
boxV2 = Box.createVerticalBox();
boxV2.add(id);
boxV2.add(Box.createVerticalStrut(8));
boxV2.add(btn1);
type.setEnabled(false);
boxV2.add(type);
boxV2.add(Box.createVerticalStrut(8));
money.setEnabled(false);
boxV2.add(money);
boxV2.add(Box.createVerticalStrut(8));
date.setEnabled(false);
boxV2.add(date);
boxV2.add(Box.createVerticalStrut(8));
remark.setEnabled(false);
boxV2.add(remark);
boxV2.add(Box.createVerticalStrut(8));
baseBox = Box.createHorizontalBox();
baseBox.add(boxV1);
boxV2.add(Box.createVerticalStrut(10));
baseBox.add(boxV2);
add(baseBox);
btn1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
DBcon dBcon=new DBcon();
Connection con=dBcon.getConn();
if(con==null){
System.out.println("數據庫查詢連接失敗");
}
else{
System.out.println("數據庫查詢連接成功");
String idString=id.getText();
if (!idString.equals("")) {
try {
Integer.parseInt(idString); // 只能為正整數
DBselect.select(idString);
} catch (Exception e2) {
// TODO: handle exception
JOptionPane.showMessageDialog(null, "ID格式不正確,請重新輸入!");
}
}
else {
JOptionPane.showMessageDialog(null, "Please input ID!");
}
//id.setText(DBselect.s);
type.setText(DBselect.Stype);
money.setText(DBselect.Smoney);
date.setText(DBselect.Sdate);
remark.setText(DBselect.Sremark);
}
}
});
}
}數據庫查詢操作:
package com.handson.entity;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;
import javax.swing.JOptionPane;
import com.tcl.util.DBcon;
public class DBselect{
public static String Stype;
public static String Smoney;
public static String Sdate;
public static String Sremark;
public static void select(String idString){
int i=0;
DBcon dBcon=new DBcon();
Connection conn=dBcon.getConn();
if(conn != null){
try {
Statement sm = conn.createStatement();
ResultSet n = sm.executeQuery("select * from TALLY where TID='"+idString+"'");
while (n.next()) {
Stype=n.getString(2);
Smoney=n.getString(3);
Sdate=n.getString(4);
Sremark=n.getString(5);
i++;
// JOptionPane.showMessageDialog(null, "Select Success!");
}
n.close();
sm.close();
conn.close();
if (i==1) {
JOptionPane.showMessageDialog(null, "Select Success!");
}
else {
JOptionPane.showMessageDialog(null, "請輸入正確的ID!");
}
}
catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
查詢全部賬目信息:
package com.handson.entity;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.Box;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;
import com.tcl.util.DBcon;
public class DBSWseleteall extends JFrame{
JTextField id = new JTextField(10);//要查詢的卡號
Box baseBox,boxV1,boxV2;
public DBSWseleteall(){
this.setBounds(100,100,450,260);
this.setTitle("查詢全部");
this.setLayout(new java.awt.FlowLayout());
init();
this.setVisible(true);
this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);//只關閉當前窗口
}
void init(){
boxV1 = Box.createVerticalBox();
boxV1.add(new JLabel("查詢結果如下:"));
boxV1.add(Box.createVerticalStrut(8));
DBcon drop=new DBcon();
Connection conn=drop.getConn();
if(conn != null){
try {
Statement sm = conn.createStatement();
ResultSet n = sm.executeQuery("select * from TALLY");//用于產生單個結果集的語句
while (n.next()) {
String id=n.getString(1);
String type=n.getString(2);
String money=n.getString(3);
String date=n.getString(4);
String remark=n.getString(5);
boxV1.add(new JLabel("ID:"+id+","+"TYPE:"+type+","+"MONEY:"+money+","+"DATE:"+date+","+"REMARK:"+remark+","));
boxV1.add(Box.createVerticalStrut(8));
}
n.close();
sm.close();
conn.close();
}
catch (SQLException i) {
// TODO Auto-generated catch block
i.printStackTrace();
}
}
baseBox = Box.createHorizontalBox();
baseBox.add(boxV1);
add(baseBox);
}
}
運行結果太多就不一一列舉了
附主運行界面:
package com.handson.main;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import com.handson.entity.DBSWseleteall;
import com.handson.services.SWdelete;
import com.handson.services.SWinsert;
import com.handson.services.SWselect;
import com.handson.services.SWupdate;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class Pinit extends JFrame{ //界面的初始化和數據庫連接
JButton jb1=null;
public static void main(String[] args)
{
Pinit frame = new Pinit();
frame.setVisible(true);
}
public Pinit()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 573, 381);
JPanel contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
getContentPane().setBackground(Color.gray);
contentPane.setLayout(null);
JButton tianjia = new JButton("INSERT");
tianjia.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SWinsert ins = new SWinsert();
}
});
tianjia.setFont(new Font("宋體", Font.PLAIN, 18));
tianjia.setBounds(91, 100, 150, 27);
contentPane.add(tianjia);
JButton xiugai = new JButton("UPDATE");
xiugai.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SWupdate up = new SWupdate();
}
});
xiugai.setFont(new Font("宋體", Font.PLAIN, 18));
xiugai.setBounds(91, 150, 150, 27);
contentPane.add(xiugai);
JButton shanchu= new JButton("DELETE");
shanchu.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SWdelete dr = new SWdelete();
}
});
shanchu.setFont(new Font("宋體", Font.PLAIN, 18));
shanchu.setBounds(91, 200, 150, 27);
contentPane.add(shanchu);
JButton zhangmu = new JButton("SELECT");
zhangmu.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
SWselect se = new SWselect();
}
});
zhangmu.setFont(new Font("宋體", Font.PLAIN, 18));
zhangmu.setBounds(300,100, 150, 27);
contentPane.add(zhangmu);
JButton quanbu = new JButton("SELECT ALL");
quanbu.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
DBSWseleteall se = new DBSWseleteall();
}
});
quanbu.setFont(new Font("宋體", Font.PLAIN, 18));
quanbu.setBounds(300,150, 150, 27);
contentPane.add(quanbu);
JButton tuichu = new JButton("EXIT");
tuichu.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
});
tuichu.setFont(new Font("宋體", Font.PLAIN, 18));
tuichu.setBounds(300,200, 150, 27);
contentPane.add(tuichu);
// 連接數據庫 測試
String URL = "jdbc:oracle:thin:@localhost:1521:ORCL";
String user = "scott";//sql用戶名
String psd = "123456";//sql密碼
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection(URL, user, psd);
Statement stat = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_READ_ONLY);
JOptionPane.showMessageDialog(null, "RUNNING。。。");
}
catch (ClassNotFoundException e)
{
JOptionPane.showMessageDialog(null, "SQL鏈接不成功!"); //未查找到相應的連接內容
}
catch (SQLException e)
{
JOptionPane.showMessageDialog(null, "FAIL!"); //數據庫未連接
}
}
}運行結果:
第三部分總結
其中用了大量的Swing界面視圖的構建,還有數據庫的連接已經進行操作。其中還對各種輸入的錯誤操作進行了錯誤提醒。就是這樣。
總結
以上是生活随笔為你收集整理的个人帐目管理系统java_Java 项目 个人帐目管理系统的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: appium java 点击事件_“按钮
- 下一篇: Java-用户交互Scanner