亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

Java實(shí)現(xiàn)簡(jiǎn)易圖書(shū)借閱系統(tǒng)

 更新時(shí)間:2022年03月11日 09:39:09   作者:禿頭也打碼  
這篇文章主要為大家詳細(xì)介紹了Java實(shí)現(xiàn)簡(jiǎn)易圖書(shū)借閱系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

在簡(jiǎn)單學(xué)習(xí)Java的基礎(chǔ)知識(shí)點(diǎn)后,動(dòng)手做了一個(gè)十分簡(jiǎn)陋的圖書(shū)館借閱系統(tǒng),作為對(duì)所學(xué)知識(shí)的綜合應(yīng)用,有不足的地方希望大家多多評(píng)論,會(huì)積極進(jìn)行改正。

1.先附上總的效果

一開(kāi)始的登錄界面

登錄界面

注冊(cè)界面

登錄進(jìn)去后的個(gè)人主頁(yè)

(本來(lái)想在上方插入一張圖片,但是剛學(xué)swing部分,搞不懂圖片的插入方式,搞了很久還是沒(méi)懂,就暫時(shí)放下了)

借書(shū)頁(yè)面

輸入關(guān)鍵詞后搜索的結(jié)果

還書(shū)界面,點(diǎn)擊自動(dòng)顯示未還書(shū)籍

查詢未還書(shū)籍的具體信息

2.貼上源代碼

1).這里簡(jiǎn)單說(shuō)一下與數(shù)據(jù)庫(kù)的操作,注冊(cè)用戶時(shí)在表person_information插入個(gè)人信息,注冊(cè)的同時(shí)創(chuàng)建專屬個(gè)人的 賬號(hào)+密碼_no_book_information 表記錄未還書(shū)籍 ,還有 賬號(hào)+密碼_already_book_information 表記錄已還書(shū)籍的信息記錄,在借書(shū)時(shí)將書(shū)籍的信息插入賬號(hào)+密碼_no_book_information 表,在還書(shū)時(shí)在
賬號(hào)+密碼_already_book_information 表插入已還書(shū)籍的信息,刪除賬號(hào)+密碼_no_book_information 表中對(duì)應(yīng)的借閱記錄。

2).首先做了一個(gè)初始化連接數(shù)據(jù)庫(kù)的類,方便在需要時(shí)調(diào)用。
(涉及數(shù)據(jù)庫(kù)方面只是簡(jiǎn)單的增刪查改,本人也是剛學(xué),不做過(guò)多的說(shuō)明)

package booksystem;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
/*
?* 用于初始化連接數(shù)據(jù)庫(kù)
?*/
public class jdbcConnection?
{
?? ?public static Connection getConnection()throws SQLException
?? ?{
?? ??? ?try
?? ??? ?{
?? ??? ??? ?Class.forName("com.mysql.jdbc.Driver");
?? ??? ??? ?
?? ??? ?}
?? ??? ?catch(ClassNotFoundException e)
?? ??? ?{
?? ??? ??? ?e.printStackTrace();
?? ??? ??? ?System.exit(0);
?? ??? ?}
?? ??? ?
?? ??? ?return DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/book_system?characterEncoding=UTF-8","root","123456789");
?? ??? ?
?? ?}

}

登錄界面

主要思路:

登錄時(shí)在數(shù)據(jù)庫(kù)中搜索是否存在該賬戶,存在進(jìn)入主頁(yè),不存在則提示錯(cuò)誤,注冊(cè)時(shí)在數(shù)據(jù)庫(kù)的用戶列表插入新用戶的信息。

package booksystem;
import javax.swing.*;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/*
?* 圖書(shū)館登錄界面的設(shè)計(jì)
?* 包括 登錄和注冊(cè)兩部分
?*?
?*/
@SuppressWarnings("serial")
public class jieMian extends JFrame ??//總頁(yè)面
{
?? ??? ?
?? ?public jieMian()
?? ?{
?? ??? ?super();
?? ??? ?
?? ??? ?JLabel label=new JLabel("歡迎來(lái)到圖書(shū)館借閱系統(tǒng)");
?? ??? ?label.setFont(new Font("宋體", 0?? ?,25));
?? ??? ?label.setBounds(100,50,300,150);
?? ??? ?
?? ??? ?
?? ??? ?JButton button=new JButton("登錄");
?? ??? ?button.addActionListener(new ActionListener()
?? ??? ??? ??? ?{

?? ??? ??? ??? ??? ?@Override
?? ??? ??? ??? ??? ?public void actionPerformed(ActionEvent e)?
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ?new dengLu();
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?
?? ??? ??? ??? ?});
?? ??? ?
?? ??? ?JButton button1=new JButton("注冊(cè)");
?? ??? ?button1.addActionListener(new ActionListener()
?? ??? ??? ??? ?{

?? ??? ??? ??? ??? ?@Override
?? ??? ??? ??? ??? ?public void actionPerformed(ActionEvent e)?
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ?new zhuCe();
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?
?? ??? ??? ??? ?});
?? ??? ?
?? ??? ?Box box=Box.createVerticalBox();
?? ??? ?box.add(button);
?? ??? ?box.add(Box.createVerticalStrut(50));
?? ??? ?box.add(button1);
?? ??? ?box.setBounds(200,250,100,150);
?? ??? ?
?? ??? ?
?? ??? ?setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
?? ??? ?setSize(500,500);
?? ??? ?setResizable(false);
?? ??? ?setLocation(700,200);
?? ??? ?setVisible(true);
?? ??? ?setLayout(null);
?? ??? ?add(label);
?? ??? ?add(box);
?? ??? ?
?? ?}
?? ?
?? ?//注冊(cè)頁(yè)面
?? ?
?? ?class zhuCe extends JFrame implements ActionListener
?? ?{
?? ??? ?private JTextField zhangHao2;
?? ??? ?private JPasswordField password2;
?? ??? ?
?? ??? ?public zhuCe()
?? ??? ?{
?? ??? ??? ?super();
?? ??? ??? ?
?? ??? ??? ?Box box=Box.createHorizontalBox();
?? ??? ??? ?zhangHao2=new JTextField(15);
?? ??? ??? ?box.add(new JLabel("賬號(hào):"));
?? ??? ??? ?box.add(Box.createHorizontalStrut(10));
?? ??? ??? ?box.add(zhangHao2);
?? ??? ??? ?
?? ??? ??? ?Box box1=Box.createHorizontalBox();
?? ??? ??? ?password2=new JPasswordField(15);
?? ??? ??? ?box1.add(new JLabel("密碼:"));
?? ??? ??? ?box1.add(Box.createHorizontalStrut(10));
?? ??? ??? ?box1.add(password2);?
?? ??? ??? ?
?? ??? ??? ?
?? ??? ??? ?JButton button=new JButton("確認(rèn)");
?? ??? ??? ?button.addActionListener(this);
?? ??? ??? ?
?? ??? ??? ?JButton button1=new JButton("重置");
?? ??? ??? ?button1.addActionListener(this);
?? ??? ??? ?
?? ??? ??? ?Box box2=Box.createHorizontalBox();
?? ??? ??? ?box2.add(Box.createHorizontalStrut(30));
?? ??? ??? ?box2.add(button);
?? ??? ??? ?box2.add(Box.createHorizontalStrut(70));
?? ??? ??? ?box2.add(button1);
?? ??? ??? ?
?? ??? ??? ?Box box3=Box.createVerticalBox();
?? ??? ??? ?box3.add(box);
?? ??? ??? ?box3.add(Box.createVerticalStrut(10));
?? ??? ??? ?box3.add(box1);
?? ??? ??? ?box3.add(Box.createVerticalStrut(10));
?? ??? ??? ?box3.add(box2);
?? ??? ??? ?box3.setBounds(100,50,250,100);
?? ??? ??? ?
?? ??? ??? ?setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
?? ??? ??? ?setSize(500,250);
?? ??? ??? ?setLayout(null);
?? ??? ??? ?setVisible(true);
?? ??? ??? ?setLocation(700,300);
?? ??? ??? ?add(box3);
?? ??? ??? ?
?? ??? ??? ?
?? ??? ?}

?? ??? ?//事件處理
?? ??? ?@Override
?? ??? ?public void actionPerformed(ActionEvent e) ?
?? ??? ?{
?? ??? ??? ?String ret=e.getActionCommand();
?? ??? ??? ?
?? ??? ??? ?if(ret.equals("確認(rèn)"))
?? ??? ??? ?{
?? ??? ??? ??? ?//需要插入一個(gè)檢驗(yàn)數(shù)據(jù)合理性并更新數(shù)據(jù)庫(kù)的操作
?? ??? ??? ??? ?String insertzh=zhangHao2.getText();
?? ??? ??? ??? ?String insertpw=new String(password2.getPassword());
?? ??? ??? ??? ?insert(insertzh,insertpw); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? //點(diǎn)擊確認(rèn)后插入數(shù)據(jù)自動(dòng)關(guān)閉
?? ??? ??? ??? ?this.dispose();
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ??? ?else
?? ??? ??? ?{
?? ??? ??? ??? ?zhangHao2.setText("");
?? ??? ??? ??? ?password2.setText("");
?? ??? ??? ?}
?? ??? ?}
?? ??? ?
?? ??? ?
?? ??? ?//處理注冊(cè)賬號(hào)密碼并插入數(shù)據(jù)庫(kù)
?? ??? ?//這里只是簡(jiǎn)單地將賬號(hào)密碼插入數(shù)據(jù)庫(kù),沒(méi)有考慮若賬號(hào)不能與之前的用戶相同還有不能用空格注冊(cè)。
?? ??? ?//處理空格的方法:提取原始賬號(hào)密碼,用trim()除去前后空格比較長(zhǎng)度做第一輪篩選,再逐個(gè)字符進(jìn)行比較
?? ??? ?private void insert(String zh,String pw)
?? ??? ?{
?? ??? ??? ?try(
?? ??? ??? ?Statement statement=jdbcConnection.getConnection().createStatement();
?? ??? ??? ?)
?? ??? ??? ?{
?? ??? ??? ??? ?String sqlsentence="insert into person_information values('"+zh+"','"+pw+"',now());";
?? ??? ??? ??? ?statement.execute(sqlsentence);
?? ??? ??? ??? ?
?? ??? ??? ??? ?String sqlsentence1="create table "+zh+pw+"_no_book_information(書(shū)名 varchar(20) not null," ? ? ? //建立一個(gè)個(gè)人的借書(shū)未還表
?? ??? ??? ??? ??? ??? ?+ "借書(shū)時(shí)間 ?datetime not null,"
?? ??? ??? ??? ??? ??? ?+ "借閱天數(shù) ?int unsigned not null,"
?? ??? ??? ??? ??? ??? ?+ "應(yīng)還時(shí)間 ?datetime not null);";
?? ??? ??? ??? ?statement.execute(sqlsentence1);
?? ??? ??? ??? ?
?? ??? ??? ??? ?//建立已還書(shū)籍記錄
?? ??? ??? ??? ?String sqlsentence2="create table "+zh+pw+"_already_book_information(書(shū)名 varchar(20) not null," ? ? ? //建立一個(gè)個(gè)人的借書(shū)未還表
?? ??? ??? ??? ??? ??? ?+ "借書(shū)時(shí)間 ?datetime not null,"
?? ??? ??? ??? ??? ??? ?+ "借閱天數(shù) ?int unsigned not null,"
?? ??? ??? ??? ??? ??? ?+ "應(yīng)還時(shí)間 ?datetime not null,"
?? ??? ??? ??? ??? ??? ?+ "歸還時(shí)間 ? datetime ?not null);"; ?
?? ??? ??? ??? ?statement.execute(sqlsentence2);
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ??? ?catch(SQLException e)
?? ??? ??? ?{
?? ??? ??? ??? ?System.out.println("注冊(cè)賬號(hào)更新數(shù)據(jù)庫(kù)時(shí)出錯(cuò)!");
?? ??? ??? ??? ?e.printStackTrace();
?? ??? ??? ??? ?System.exit(0);
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ?}? ? ? ?
?? ?}
?? ?

?? ?//登錄界面
?? ?
?? ?class dengLu extends JFrame implements ActionListener
?? ?{
?? ??? ?private JTextField zhangHao1;
?? ??? ?private JPasswordField password1;
?? ??? ?
?? ??? ?public dengLu
?? ??? ?()
?? ??? ?{
?? ??? ??? ?super();
?? ??? ??? ?
?? ??? ??? ?Box box=Box.createHorizontalBox();
?? ??? ??? ?zhangHao1=new JTextField(15);
?? ??? ??? ?box.add(new JLabel("賬號(hào):"));
?? ??? ??? ?box.add(Box.createHorizontalStrut(10));
?? ??? ??? ?box.add(zhangHao1);
?? ??? ??? ?
?? ??? ??? ?Box box1=Box.createHorizontalBox();
?? ??? ??? ?password1=new JPasswordField(15);
?? ??? ??? ?box1.add(new JLabel("密碼:"));
?? ??? ??? ?box1.add(Box.createHorizontalStrut(10));
?? ??? ??? ?box1.add(password1);?
?? ??? ??? ?
?? ??? ??? ?
?? ??? ??? ?JButton button=new JButton("確認(rèn)");
?? ??? ??? ?button.addActionListener(this);
?? ??? ??? ?
?? ??? ??? ?Box box2=Box.createHorizontalBox();
?? ??? ??? ?box2.add(Box.createHorizontalStrut(30));
?? ??? ??? ?box2.add(button);

?? ??? ??? ?Box box3=Box.createVerticalBox();
?? ??? ??? ?box3.add(box);
?? ??? ??? ?box3.add(Box.createVerticalStrut(10));
?? ??? ??? ?box3.add(box1);
?? ??? ??? ?box3.add(Box.createVerticalStrut(10));
?? ??? ??? ?box3.add(box2);
?? ??? ??? ?
?? ??? ??? ?box3.setBounds(100,50,250,100);
?? ??? ??? ?
?? ??? ??? ?setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
?? ??? ??? ?setSize(500,250);
?? ??? ??? ?setLayout(null);
?? ??? ??? ?setVisible(true);
?? ??? ??? ?setLocation(700,300);
?? ??? ??? ?add(box3);
?? ??? ??? ?
?? ??? ?}

?? ??? ?@Override
?? ??? ?public void actionPerformed(ActionEvent e)?
?? ??? ?{
?? ??? ??? ?
?? ??? ??? ??? ?//需要插入一個(gè)檢驗(yàn)數(shù)據(jù)合理性并更新數(shù)據(jù)庫(kù)的操作
?? ??? ??? ?String select=zhangHao1.getText();
?? ??? ??? ?String select1=new String(password1.getPassword());? ? ? //注意getPassword方法返回的時(shí)char數(shù)組
?? ??? ??? ?
?? ??? ??? ?select(select,select1);? ? ?//處理事件?
?? ??? ??? ?
?? ??? ?}
?? ??? ?
?? ??? ?
?? ??? ?private void select(String zh1,String pw1)
?? ??? ?{
?? ??? ??? ?try(
?? ??? ??? ?Statement statement1=jdbcConnection.getConnection().createStatement();
?? ??? ??? ?)
?? ??? ??? ?{
?? ??? ??? ??? ?String sqlsentence1="select * from person_information where ?賬號(hào)='"+zh1+"';";
?? ??? ??? ??? ?System.out.println(sqlsentence1);
?? ??? ??? ??? ?ResultSet set=statement1.executeQuery(sqlsentence1);
?? ??? ??? ??? ?
?? ??? ??? ??? ?
?? ??? ??? ??? ?if(!set.next())
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?zhangHao1.setText("無(wú)此賬號(hào)!");? ? ? //查詢數(shù)據(jù)庫(kù)發(fā)現(xiàn)無(wú)此賬號(hào)記錄
?? ??? ??? ??? ?}
?? ??? ??? ??? ?else
?? ??? ??? ??? ??? ?if(set.getString("密碼").equals(pw1))
?? ??? ??? ??? ?{
?? ??? ??? ??? ??? ?new zhuYe(zh1,pw1);??//這里應(yīng)該新建一個(gè)賬號(hào)主頁(yè)
?? ??? ??? ??? ??? ?this.dispose();? ? //若輸入正確的賬號(hào)密碼,則次登錄窗口消失,進(jìn)入賬號(hào)主頁(yè)
?? ??? ??? ??? ? ? ?
?? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?else
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ?zhangHao1.setText("密碼錯(cuò)誤!"); ? ? ? ? ? ? ? ? ? //顯示密碼錯(cuò)誤
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ??? ?catch(SQLException e)
?? ??? ??? ?{
?? ??? ??? ??? ?System.out.println("注冊(cè)賬號(hào)更新數(shù)據(jù)庫(kù)時(shí)出錯(cuò)!");
?? ??? ??? ??? ?e.printStackTrace();
?? ??? ??? ??? ?System.exit(0);
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ?}
?? ??? ?
?? ??? ??? ??? ??? ??? ?
?? ?}?? ??? ??? ??? ?
}

主頁(yè)部分

主要思路:

主要包括三個(gè)按鈕對(duì)應(yīng)三個(gè)功能塊

package booksystem;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/*
?* 個(gè)人主頁(yè)
?*?
?*/

@SuppressWarnings("serial")
public class zhuYe extends JFrame?
{
?? ?static String zh;
?? ?static String pw;
?? ?
?? ?public zhuYe(String zh,String pw)
?? ?{
?? ??? ?super(zh+"的主頁(yè)");
?? ??? ?zhuYe.zh=zh;
?? ??? ?zhuYe.pw=pw;
?? ??? ?
?? ??? ?JButton button=new JButton("借書(shū)");
?? ??? ?button.setBounds(450,550,150,50);
?? ??? ?button.addActionListener(new ActionListener()
?? ??? ??? ??? ?{

?? ??? ??? ??? ??? ?@Override
?? ??? ??? ??? ??? ?public void actionPerformed(ActionEvent arg0) {
?? ??? ??? ??? ??? ??? ?new selectBook();
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ?});
?? ??? ?
?? ??? ?JButton button1=new JButton("還書(shū)");
?? ??? ?button1.setBounds(450,650,150,50);
?? ??? ?button1.addActionListener(new ActionListener()
?? ??? ??? ??? ?{

?? ??? ??? ??? ??? ?@Override
?? ??? ??? ??? ??? ?public void actionPerformed(ActionEvent arg0) {
?? ??? ??? ??? ??? ??? ?new returnBook();
?? ??? ??? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ??? ?});
?? ??? ?
?? ??? ?JButton button2=new JButton("查詢");
?? ??? ?button2.setBounds(450,750,150,50);
?? ??? ?button2.addActionListener(new ActionListener()
?? ??? ??? ??? ?{

?? ??? ??? ??? ??? ?@Override
?? ??? ??? ??? ??? ?public void actionPerformed(ActionEvent arg0)?
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ?new findNoReturnBook();
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ??? ?});
?? ??? ?
?? ??? ?add(button);
?? ??? ?add(button1);
?? ??? ?add(button2);
?? ??? ?
?? ??? ?setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
?? ??? ?setSize(1000,1000);
?? ??? ?setLocation(400,30);
?? ??? ?setLayout(null);
?? ??? ?setVisible(true);
?? ?}
?? ??? ??? ?
?? ?

}

借書(shū)部分

輸入關(guān)鍵詞,搜索數(shù)據(jù)庫(kù)的圖書(shū)列表,將相關(guān)的書(shū)籍顯示于列表框上,借閱天數(shù)默認(rèn)為10天。

package booksystem;

import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;

import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;

@SuppressWarnings("serial")
public class selectBook extends JFrame?
{
?? ?private JTextField textSelect;? ? ? //用戶輸入關(guān)鍵詞搜索的文本框
?? ?private JTextField textDay;? ? ? //用戶輸入借閱天數(shù)的文本框
?? ?private JList<String> list;? ? ? ?//顯示搜索結(jié)果的文本列表
?? ?private Vector<String> bookSelect; //根據(jù)關(guān)鍵字在數(shù)據(jù)庫(kù)中搜尋得到的書(shū)列表,作為JList的參數(shù)
?? ?private String bookName;? ?//在輸入關(guān)鍵字查詢列表中被選中的書(shū)名
?? ?private String borrowDay="10";? //借閱天數(shù)默認(rèn)為10天
?? ?
?? ?public selectBook()
?? ?{
?? ??? ?super();
?? ??? ?
?? ??? ?textSelect=new JTextField();
?? ??? ?textSelect.setPreferredSize(new Dimension(500,30));
?? ??? ?
?? ??? ?bookSelect=new Vector<String>();
?? ? ?
?? ??? ?JButton button=new JButton("搜索");? ? ?//搜索按鈕
?? ??? ?button.addActionListener(new ActionListener()
?? ??? ??? ??? ?{

?? ??? ??? ??? ??? ?@Override
?? ??? ??? ??? ??? ?public void actionPerformed(ActionEvent arg0) {
?? ??? ??? ??? ??? ??? ?String keyBookName=textSelect.getText().trim();? ?//獲取用戶輸入關(guān)鍵詞,然后對(duì)關(guān)鍵詞去除前后空格
?? ??? ??? ??? ??? ??? ?selectBookName(keyBookName); //調(diào)用函數(shù)
?? ??? ??? ??? ??? ??? ?list.setListData(bookSelect);? //添加搜索的數(shù)據(jù)
?? ??? ??? ??? ??? ??? ?list.repaint();? ? //重繪列表 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
?? ??? ??? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ??? ?});

?? ??? ?Box box=Box.createHorizontalBox();
?? ??? ?box.add(textSelect);
?? ??? ?box.add(Box.createHorizontalStrut(30));
?? ??? ?box.add(button);
?? ??? ?box.setBounds(180,100,600,30);
?? ?
?? ??? ?add(box);
?? ??? ?
?? ??? ?Font font=new Font("宋體",0,20);
?? ??? ?
?? ??? ?list=new JList<String>();? ? ?//顯示搜索得到的相關(guān)書(shū)籍
?? ??? ?list.setPreferredSize(new Dimension(200, 100));
?? ??? ?list.setFont(font);
?? ??? ?list.setListData(bookSelect);
?? ??? ?list.addListSelectionListener(new ListSelectionListener()
?? ??? ??? ??? ?{

?? ??? ??? ??? ??? ?@Override
?? ??? ??? ??? ??? ?public void valueChanged(ListSelectionEvent arg0)?
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ?bookName=list.getSelectedValue();? ?//bookName為用戶點(diǎn)擊可能借閱的書(shū)名
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?
?? ??? ??? ??? ?});
?? ??? ?
?? ??? ?//添加滾動(dòng)條
?? ??? ?JScrollPane scroll=new JScrollPane(list,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS ,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
?? ??? ?scroll.setBounds(100,150,800,500);
?? ??? ?
? ? ? ? add(scroll);
?? ??? ?
? ? ? ? JLabel label=new JLabel("天數(shù):");
? ? ? ? label.setBounds(350,650,100,50);
? ? ? ??
? ? ? ? add(label);
? ? ? ??
? ? ? ? textDay=new JTextField();
?? ??? ?textDay.setBounds(400,665,50,20);
?? ??? ?
?? ??? ?add(textDay);
?? ??? ?
?? ??? ?
?? ??? ?JButton button1=new JButton("借閱");
?? ??? ?button1.setBounds(380,700,70,35);
?? ??? ?button1.addActionListener(new ActionListener()
?? ??? ?
?? ??? ??? ??? ?{

?? ??? ??? ??? ??? ?@Override
?? ??? ??? ??? ??? ?public void actionPerformed(ActionEvent arg0) {
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ?if(bookName!=null)? ? ?//調(diào)用更新數(shù)據(jù)庫(kù)的信息
?? ??? ??? ??? ??? ??? ?{
? ? ? ? ? ? ? ? ? ? ? ? String tempt=textDay.getText(); //判斷用戶是否有輸入借閱天數(shù),沒(méi)有默認(rèn)為10天
?? ??? ??? ??? ??? ??? ??? ?if(!tempt.equals(""))
?? ??? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ??? ?borrowDay=tempt;
?? ??? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ??? ?System.out.println(tempt);
?? ??? ??? ??? ??? ??? ??? ?updateInformation();
?? ??? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ??? ?else
?? ??? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ??? ?System.out.println("還未確定借閱的書(shū)籍!");
?? ??? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ??? ?});
?? ??? ?
?? ??? ?add(button1);
?? ??? ?
?? ??? ?setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
?? ??? ?setSize(1000,800);
?? ??? ?setLocation(400,200);
?? ??? ?setLayout(null);
?? ??? ?setVisible(true);
?? ??? ?
?? ?}

?? ?//連接數(shù)據(jù)庫(kù)
?? ?private void selectBookName(String name)
?? ?{
?? ??? ?String[] tempt=name.split(""); //對(duì)用戶輸入的關(guān)鍵字進(jìn)行簡(jiǎn)單的除去空格處理
?? ??? ?name="%";
?? ??? ?
?? ??? ?for(int i=0;i<tempt.length;++i)? //將用戶輸入的關(guān)鍵詞做數(shù)據(jù)庫(kù)的模糊查詢處理
?? ??? ?{
?? ??? ??? ?if(!tempt[i].equals(" "))
?? ??? ??? ?{
?? ??? ??? ??? ?name=name+tempt[i]+"%";
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ?}
?? ??? ?
?? ??? ?try
?? ??? ?( Statement statement=jdbcConnection.getConnection().createStatement(); ) ? ? ? ? ? ? ? ? ?//連接數(shù)據(jù),搜索數(shù)據(jù)庫(kù)返回搜索結(jié)果
?? ??? ?{
?? ??? ??? ?String sql="select * from book_information where 書(shū)名 like '"+name+"';";
?? ??? ??? ?
?? ??? ??? ?ResultSet set=statement.executeQuery(sql);
?? ??? ??? ?
?? ??? ??? ?while(set.next())
?? ??? ??? ?{
?? ??? ??? ??? ?bookSelect.add(set.getString("書(shū)名"));
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?for(int i=0;i<bookSelect.size();++i) //控制臺(tái)顯示模糊查詢的結(jié)果,優(yōu)化時(shí)可以作為文件儲(chǔ)存
?? ??? ??? ?{
?? ??? ??? ??? ?System.out.println(bookSelect.get(i));
?? ??? ??? ?}
?? ??? ?
?? ??? ??? ?
?? ??? ??? ?if(bookSelect==null)
?? ??? ??? ?{
?? ??? ??? ??? ?bookSelect.add("暫無(wú)該書(shū)籍!");
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?
?? ??? ?}
?? ??? ?catch(SQLException e)
?? ??? ?{
?? ??? ??? ?System.out.println("根據(jù)關(guān)鍵字模糊查詢時(shí)出錯(cuò)!");
?? ??? ??? ?e.printStackTrace();
?? ??? ??? ?System.exit(0);
?? ??? ?}
?? ??? ?
?? ??? ?
?? ?}
?? ?
?? ?//點(diǎn)擊借閱按鈕后更新數(shù)據(jù)庫(kù)的信息
?? ?/*
?? ? * 先將圖書(shū)館中對(duì)應(yīng)的書(shū)籍?dāng)?shù)量減一
?? ? * 再將借閱的記錄更新至個(gè)人的借閱未還記錄表中
?? ? */
?? ?private void updateInformation()
?? ?{
?? ??? ?try ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
?? ??? ?( Statement statement=jdbcConnection.getConnection().createStatement(); )
?? ??? ?{
?? ??? ??? ?String sql="select * from book_information where 書(shū)名='"+bookName+"';"; ? ? ? ? ? ? ? ??
?? ??? ??? ?ResultSet set=statement.executeQuery(sql);
?? ??? ??? ?
?? ??? ??? ?if(set.next()) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?//搜索不到這種書(shū)的信息,退出系統(tǒng)
?? ??? ??? ?{
?? ??? ??? ??? ?Integer number=set.getInt("數(shù)量")-1;
?? ??? ??? ??? ?String sql1="update book_information set 數(shù)量="+number+" ?where 書(shū)名='"+bookName+"';";
?? ??? ??? ??? ?statement.execute(sql1);
?? ??? ??? ??? ?System.out.println(sql1);
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ??? ?else
?? ??? ??? ?{
?? ??? ??? ??? ?System.out.println("沒(méi)有這種書(shū)的記錄!");
?? ??? ??? ??? ?System.exit(0);
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?String sql2="insert into "+zhuYe.zh+zhuYe.pw+"_no_book_information ?values('"+bookName+"',now(),"+borrowDay+",now()+interval "+borrowDay+" day);";
?? ??? ??? ?System.out.println(sql2);
? ? ? ? ? ? statement.execute(sql2);
?? ??? ??? ?
?? ??? ??? ?
?? ??? ?}
?? ??? ?catch(SQLException e)
?? ??? ?{
?? ??? ??? ?System.out.println("借閱更新書(shū)籍時(shí)出錯(cuò)!");
?? ??? ??? ?e.printStackTrace();
?? ??? ??? ?System.exit(0);
?? ??? ?}
?? ??? ?
?? ?}? ??

}

還書(shū)部分

自動(dòng)查詢?cè)撡~戶未還書(shū)籍顯示在列表框中,可以點(diǎn)擊對(duì)應(yīng)書(shū)籍還書(shū)。

package booksystem;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import javax.swing.*;
/*
?* 還書(shū)
?*?
?* 當(dāng)界面做好后,在還書(shū)時(shí)若沒(méi)有查詢到書(shū)本的信息說(shuō)明書(shū)名輸入錯(cuò)誤,這里直接退出程序,可以優(yōu)化為提示輸入錯(cuò)誤并重新輸入書(shū)名
?*/
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
/*
?* 還書(shū)
?*?
?*/

@SuppressWarnings("serial")
public class returnBook ?extends JFrame
{
?? ?private String bookName;? ? ?//書(shū)名
?? ?private String borrowTime;? ? //借閱天數(shù)
?? ?private JList<String> list;? ? //未還書(shū)籍的列表
?? ?private Vector<String> bookSelect;? ? //未還書(shū)籍列表,作為JList的參數(shù)
?? ?
?? ?//窗口界面初始化
?? ?public returnBook()
?? ?{
?? ??? ?super();
?? ??? ?bookSelect=new Vector<String>();
?? ??? ?findBook(zhuYe.zh,zhuYe.pw);? ? ?//初始化bookSelect作為JList的內(nèi)容參數(shù)
?? ??? ?
? ? ? ? Font font=new Font("宋體",0,20);
?? ??? ?
?? ??? ?list=new JList<String>(); ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
?? ??? ?list.setPreferredSize(new Dimension(200, 100));
?? ??? ?list.setListData(bookSelect);
?? ??? ?list.setFont(font);
?? ??? ?list.addListSelectionListener(new ListSelectionListener()
?? ??? ??? ??? ?{

?? ??? ??? ??? ??? ?@Override
?? ??? ??? ??? ??? ?public void valueChanged(ListSelectionEvent arg0)?
?? ??? ??? ??? ??? ?{
?? ??? ??? ??? ??? ??? ? String[] tempt=list.getSelectedValue().split(">>");? //將用戶選中的書(shū)名和借書(shū)時(shí)間分開(kāi)存放
?? ??? ??? ??? ??? ??? ??
?? ??? ??? ??? ??? ??? ? if(tempt[0]!=null)? ?//判斷字符串處理是否有異常,有異常則退出程序
?? ??? ??? ??? ??? ??? ? {
?? ??? ??? ??? ??? ??? ? ? ?bookName=tempt[0];
?? ??? ??? ??? ??? ??? ? }
?? ??? ??? ??? ??? ??? ? else
?? ??? ??? ??? ??? ??? ? {
?? ??? ??? ??? ??? ??? ??? ? System.out.println("書(shū)名為空!");
?? ??? ??? ??? ??? ??? ??? ? System.exit(0);
?? ??? ??? ??? ??? ??? ? }
?? ??? ??? ??? ??? ??? ??
?? ??? ??? ??? ??? ??? ? if(tempt[1]!=null)
?? ??? ??? ??? ??? ??? ? {
?? ??? ??? ??? ??? ??? ? ? ?borrowTime=tempt[1];
?? ??? ??? ??? ??? ??? ? }
?? ??? ??? ??? ??? ??? ? else
?? ??? ??? ??? ??? ??? ? {
?? ??? ??? ??? ??? ??? ??? ? System.out.println("借書(shū)時(shí)間為空!");
?? ??? ??? ??? ??? ??? ??? ? System.exit(0);
?? ??? ??? ??? ??? ??? ? }
?? ??? ??? ??? ??? ??? ??
?? ??? ??? ??? ??? ??? ? System.out.println(bookName+borrowTime);
?? ??? ??? ??? ??? ??? ??
?? ??? ??? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?
?? ??? ??? ??? ?});
?? ??? ?
?? ??? ?JScrollPane scroll=new JScrollPane(list,ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS ,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
?? ??? ?scroll.setBounds(100,150,800,500);
?? ??? ?

?? ??? ?JButton button1=new JButton("歸還");? ?//點(diǎn)擊按鈕,歸還書(shū)籍
?? ??? ?button1.setBounds(400,670,70,35);
?? ??? ?button1.addActionListener(new ActionListener()
?? ??? ?
?? ??? ??? ??? ?{

?? ??? ??? ??? ??? ?@Override
?? ??? ??? ??? ??? ?public void actionPerformed(ActionEvent arg0) {
?? ??? ??? ??? ??? ??? ?if(bookName!=null) ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
?? ??? ??? ??? ??? ??? ?updateNumber();
?? ??? ??? ??? ??? ??? ?//list.repaint();? ? ?//想要再歸還書(shū)籍后刷新頁(yè)面,不成功
?? ??? ??? ??? ??? ??? ?
?? ??? ??? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ??? ?});
? ? ? ??
? ? ? ? setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
? ? ? ? setSize(1000,800);
?? ??? ?setLocation(400,200);
?? ??? ?setLayout(null);
?? ??? ?setVisible(true);
?? ??? ?add(scroll);
?? ??? ?add(button1);
?? ??? ?
?? ?}
? ??
?? ?/*
?? ? * 在圖書(shū)館總圖書(shū)目錄中更新書(shū)籍的數(shù)量
?? ? * 然后在個(gè)人借閱未還記錄中刪除記錄,再在個(gè)人已還記錄中插入記錄
?? ? *?
?? ? */
?? ?
?? ?private void updateNumber()
?? ?{
?? ??? ?try(
?? ??? ?Statement statement=jdbcConnection.getConnection().createStatement();? ?//直接調(diào)用函數(shù)連接數(shù)據(jù)庫(kù) ? ? ? ? ? ? ??? ?
?? ??? ??? ??? ?)
?? ??? ?{
?? ??? ??? ?String sql1="select * from book_information where 書(shū)名='"+bookName+"';";? ? //這里的數(shù)量和書(shū)名有待檢查修改
?? ??? ??? ?System.out.println(sql1);
?? ??? ??? ?ResultSet set=statement.executeQuery(sql1);
?? ??? ??? ?
?? ??? ??? ?if(set.next())? ?//搜索不到這種書(shū)的信息,退出系統(tǒng)
?? ??? ??? ?{
?? ??? ??? ??? ?Integer number=set.getInt("數(shù)量")+1;
?? ??? ??? ??? ?String sql2="update book_information set 數(shù)量="+number+" ?where 書(shū)名='"+bookName+"';";
?? ??? ??? ??? ?statement.execute(sql2);
?? ??? ??? ??? ?System.out.println(sql2);
?? ??? ??? ??? ?
?? ??? ??? ?}
?? ??? ??? ?else
?? ??? ??? ?{
?? ??? ??? ??? ?System.out.println("沒(méi)有這種書(shū)的記錄!");
?? ??? ??? ??? ?System.exit(0);
?? ??? ??? ?}
? ? ? ? ? ??
?? ??? ??? ?String sql="select * from "+zhuYe.zh+zhuYe.pw+"_no_book_information ?where 書(shū)名='"+bookName+"' and 借書(shū)時(shí)間='"+borrowTime+"';";
?? ??? ??? ?ResultSet set1=statement.executeQuery(sql);
?? ??? ??? ?
?? ??? ??? ?if(set1.next())
?? ??? ??? ?{
?? ??? ??? ?String sql3="insert into "+zhuYe.zh+zhuYe.pw+"_already_book_information values('"+set1.getString("書(shū)名")+"','"+set1.getString("借書(shū)時(shí)間")+"',"+set1.getString("借閱天數(shù)")+",'"+set1.getString("應(yīng)還時(shí)間")+"',"+"now());";
?? ??? ??? ?System.out.println(sql3);
?? ??? ??? ?statement.execute(sql3);
?? ??? ??? ?
?? ??? ??? ?String sql4="delete from "+zhuYe.zh+zhuYe.pw+"_no_book_information where 書(shū)名='"+bookName+"' and 借書(shū)時(shí)間='"+borrowTime+"';";
?? ??? ??? ?System.out.println(sql4);
?? ??? ??? ?statement.execute(sql4);
?? ??? ??? ?
?? ??? ??? ?}
?? ??? ??? ?else
?? ??? ??? ?{
?? ??? ??? ??? ?System.out.println(zhuYe.zh+"沒(méi)有這種書(shū)的借閱記錄!");
?? ??? ??? ??? ?System.exit(0);
?? ??? ??? ?}
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?
?? ??? ??? ?
?? ??? ?}
?? ??? ?catch(SQLException g)
?? ??? ?{
?? ??? ??? ?System.out.println("更新數(shù)據(jù)時(shí)出錯(cuò)!");
?? ??? ??? ?g.printStackTrace();
?? ??? ??? ?System.exit(0);
?? ??? ??? ?
?? ??? ?}
?? ??? ?
?? ?}
?? ?
?? ?private void findBook(String zh,String pw) //從數(shù)據(jù)庫(kù)中搜索表返回未歸還書(shū)名初始化bookSelect
?? ?{
?? ??? ?try
?? ??? ?( ?Statement statement1=jdbcConnection.getConnection().createStatement(); ? ? )
?? ??? ?{
?? ??? ??? ?String sql5="select * from "+zh+pw+"_no_book_information;";
?? ??? ??? ?ResultSet returnSet=statement1.executeQuery(sql5);
?? ??? ??? ?
?? ??? ??? ??? ?
?? ??? ??? ?while(returnSet.next())
?? ??? ??? ?{
?? ??? ??? ??? ?String name=returnSet.getString("書(shū)名")+">>"+returnSet.getString("借書(shū)時(shí)間"); ? ? ? ? ? ? ? ?//顯示書(shū)名和借書(shū)時(shí)間,這樣允許不同時(shí)間借同一本書(shū)
?? ??? ??? ??? ?
?? ??? ??? ??? ?bookSelect.add(name);
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?if(bookSelect.size()==0)? ? ?//如果沒(méi)有借閱記錄
?? ??? ??? ?{
?? ??? ??? ??? ?bookSelect.add("暫無(wú)借閱記錄!");
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?
?? ??? ?}
?? ??? ?catch(SQLException e)
?? ??? ?{
?? ??? ??? ?System.out.println("還書(shū)搜索未還書(shū)籍出錯(cuò)!");
?? ??? ??? ?e.printStackTrace();
?? ??? ??? ?System.exit(0);
?? ??? ?}
?? ?}
??
}

查詢部分

查詢個(gè)人賬號(hào)的未還書(shū)籍具體信息,顯示在表格中。

package booksystem;
import java.awt.*;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Vector;
import javax.swing.*;

/*
?*?
?* 查詢還未歸還的書(shū)籍
?*/
@SuppressWarnings("serial")
public class findNoReturnBook extends JFrame ?
{

?? ?private Vector<Vector<String>> rowData;
?? ?
?? ?public findNoReturnBook()
?? ?{
?? ??? ?super();
?? ??? ?rowData=new Vector<Vector<String>>();
?? ??? ?Vector<String> columnNames=new Vector<String>();
?? ??? ?columnNames.add("書(shū)名");
?? ??? ?columnNames.add("借書(shū)時(shí)間");
?? ??? ?columnNames.add("借閱天數(shù)");
?? ??? ?columnNames.add("應(yīng)還時(shí)間");
?? ??? ?findBook(); ?//初始化rowData
?? ??? ?
?? ??? ?JTable table=new JTable(rowData,columnNames);
?? ??? ?JScrollPane pane=new JScrollPane(table);
?? ??? ?table.setPreferredScrollableViewportSize(new Dimension(400, 300));
?? ??? ?
?? ??? ?setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
?? ??? ?setSize(800,600);
?? ??? ?setLayout(new BorderLayout());
?? ??? ?add(pane,BorderLayout.CENTER);
?? ??? ?setLocation(500,200);
?? ??? ?setVisible(true);

?? ?}

?? ?private void findBook() ? ? ? //查詢數(shù)據(jù),并用容器收集起來(lái)
?? ?{
?? ??? ?try(
?? ??? ?Statement statement=jdbcConnection.getConnection().createStatement();
?? ??? ?)
?? ??? ?{
?? ??? ??? ?String sql="select * from "+zhuYe.zh+zhuYe.pw+"_no_book_information;";
?? ??? ??? ?ResultSet result=statement.executeQuery(sql);
?? ??? ??? ?
?? ??? ??? ?while(result.next())
?? ??? ??? ?{
?? ??? ??? ??? ?Vector<String> tempt=new Vector<String>();
?? ??? ??? ??? ?tempt.add(result.getString("書(shū)名"));
?? ??? ??? ??? ?tempt.add(result.getString("借書(shū)時(shí)間"));
?? ??? ??? ??? ?tempt.add(result.getString("借閱天數(shù)"));
?? ??? ??? ??? ?tempt.add(result.getString("應(yīng)還時(shí)間"));
?? ??? ??? ??? ?
?? ??? ??? ??? ?if(tempt!=null)
?? ??? ??? ??? ?rowData.add(tempt);
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?if(rowData==null)
?? ??? ??? ?{
?? ??? ??? ??? ?Vector<String> tempt=new Vector<String>();
?? ??? ??? ??? ?tempt.add("暫無(wú)借閱數(shù)據(jù)");
?? ??? ??? ??? ?rowData.add(tempt);
?? ??? ??? ?}
?? ??? ??? ?
?? ??? ??? ?
?? ??? ?}
?? ??? ?catch(SQLException |NullPointerException a)
?? ??? ?{
?? ??? ??? ?System.out.println("查詢數(shù)據(jù)出錯(cuò)!");
?? ??? ??? ?a.printStackTrace();
?? ??? ??? ?System.exit(0);
?? ??? ??? ?
?? ??? ?}
?? ?}
?? ?

}

總結(jié):

1).swing的界面設(shè)計(jì)很不熟練。(個(gè)人也覺(jué)得用這個(gè)工具包設(shè)計(jì)界面很是麻煩)
2).做項(xiàng)目的過(guò)程將界面和功能的實(shí)現(xiàn)混在一起,不利于后期的修改。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Java類中this關(guān)鍵字與static關(guān)鍵字的用法解析

    Java類中this關(guān)鍵字與static關(guān)鍵字的用法解析

    這篇文章主要介紹了Java類中this關(guān)鍵字與static關(guān)鍵字的用法解析,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下
    2022-09-09
  • Spring Boot 通過(guò) Mvc 擴(kuò)展方便進(jìn)行貨幣單位轉(zhuǎn)換的代碼詳解

    Spring Boot 通過(guò) Mvc 擴(kuò)展方便進(jìn)行貨幣單位轉(zhuǎn)換的代碼詳解

    這篇文章主要介紹了Spring Boot 通過(guò) Mvc 擴(kuò)展方便進(jìn)行貨幣單位轉(zhuǎn)換,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-12-12
  • java 網(wǎng)絡(luò)編程之TCP通信和簡(jiǎn)單的文件上傳功能實(shí)例

    java 網(wǎng)絡(luò)編程之TCP通信和簡(jiǎn)單的文件上傳功能實(shí)例

    下面小編就為大家分享一篇java 網(wǎng)絡(luò)編程之TCP通信和簡(jiǎn)單的文件上傳功能實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-01-01
  • 詳解在Spring Boot中使用Mysql和JPA

    詳解在Spring Boot中使用Mysql和JPA

    本文向你展示如何在Spring Boot的Web應(yīng)用中使用Mysq數(shù)據(jù)庫(kù),也充分展示Spring Boot的優(yōu)勢(shì)
    2017-04-04
  • java實(shí)現(xiàn)多人聊天工具(socket+多線程)

    java實(shí)現(xiàn)多人聊天工具(socket+多線程)

    這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)多人聊天工具,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-08-08
  • springboot整合logback實(shí)現(xiàn)日志管理操作

    springboot整合logback實(shí)現(xiàn)日志管理操作

    本章節(jié)是記錄logback在springboot項(xiàng)目中的簡(jiǎn)單使用,本文將會(huì)演示如何通過(guò)logback將日志記錄到日志文件或輸出到控制臺(tái)等管理操作,感興趣的朋友跟隨小編一起看看吧
    2024-02-02
  • Java實(shí)現(xiàn)單鏈表SingleLinkedList增刪改查及反轉(zhuǎn) 逆序等

    Java實(shí)現(xiàn)單鏈表SingleLinkedList增刪改查及反轉(zhuǎn) 逆序等

    單鏈表是鏈表的其中一種基本結(jié)構(gòu)。一個(gè)最簡(jiǎn)單的結(jié)點(diǎn)結(jié)構(gòu)如圖所示,它是構(gòu)成單鏈表的基本結(jié)點(diǎn)結(jié)構(gòu)。在結(jié)點(diǎn)中數(shù)據(jù)域用來(lái)存儲(chǔ)數(shù)據(jù)元素,指針域用于指向下一個(gè)具有相同結(jié)構(gòu)的結(jié)點(diǎn)。 因?yàn)橹挥幸粋€(gè)指針結(jié)點(diǎn),稱為單鏈表
    2021-10-10
  • Java實(shí)現(xiàn)猜數(shù)程序

    Java實(shí)現(xiàn)猜數(shù)程序

    這篇文章主要為大家詳細(xì)介紹了Java實(shí)現(xiàn)猜數(shù)程序,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-12-12
  • SpringBoot整合ActiveMQ的詳細(xì)步驟

    SpringBoot整合ActiveMQ的詳細(xì)步驟

    昨天仔細(xì)研究了activeMQ消息隊(duì)列,也遇到了些坑,下面這篇文章主要給大家介紹了關(guān)于SpringBoot整合ActiveMQ的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-11-11
  • java獲取中文拼音首字母的實(shí)例

    java獲取中文拼音首字母的實(shí)例

    下面小編就為大家?guī)?lái)一篇java獲取中文拼音首字母的實(shí)例。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-09-09

最新評(píng)論