├── 1-09-07.png ├── Back.java ├── Back.java.java ├── Book.java ├── BookAdd.java ├── BookDelete.java ├── BookQuery.java ├── BookQueryImprove.java ├── BookSelect.java ├── BookUpdate.java ├── Borrow.java ├── ChangePassWord.java ├── DbOp.java ├── GlobalVar.java ├── IfBorrowBack.java ├── Login.java ├── Reader.java ├── ReaderAdd.java ├── ReaderDelete.java ├── ReaderQuery.java ├── ReaderSelect.java ├── ReaderUpdate.java ├── ShowMain.java ├── Untitled-4.png ├── bookbk.png ├── bookdb.sql ├── dir.cmd ├── dir.txt ├── login.png ├── mainbk.png ├── querybk.png ├── readme.md ├── start.bat └── 图书管理 .mdb /1-09-07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/1-09-07.png -------------------------------------------------------------------------------- /Back.java: -------------------------------------------------------------------------------- 1 | //Back.java; 2 | import java.awt.*; 3 | import java.awt.event.*; 4 | import java.sql.*; 5 | import java.util.Date; 6 | import java.util.*; 7 | import java.text.*; 8 | import javax.swing.JOptionPane; 9 | 10 | public class Back extends Frame { 11 | /** 12 | * 13 | */ 14 | private static final long serialVersionUID = 7670129939284773294L; 15 | Label bookidlb = new Label("图书编号"), readeridlb = new Label("读者编号"); 16 | TextField bookidtxt = new TextField(), readeridtxt = new TextField(); 17 | Button querybtn = new Button("查询"), borrowbtn = new Button("还书"), 18 | closebtn = new Button("清除"); 19 | String SepLine = "--------------------------------------------------"; 20 | String[] sep = { "图书信息", "读者信息", "借阅信息" }; 21 | Label[] seplabel = new Label[3]; 22 | String[] optionname = { "书名:", "作者:", "出版社:", "出版时间:", "定价:", "存量:", "姓名:","类型:", "可借数:", "可借天数:", "借阅日期:","阅读天数:","还书日期" }; 23 | Label[] alloption = new Label[13]; 24 | Label[] showoption = new Label[13]; 25 | 26 | public Back() { 27 | setTitle("图书归还"); 28 | setLayout(null); 29 | setSize(500, 470); 30 | setResizable(false); 31 | this.setForeground(Color.BLACK); 32 | bookidlb.setBounds(50, 50, 50, 20); 33 | bookidtxt.setBounds(110, 50, 100, 20); 34 | readeridlb.setBounds(220, 50, 50, 20); 35 | readeridtxt.setBounds(280, 50, 100, 20); 36 | querybtn.setBounds(400, 50, 50, 20); 37 | add(bookidlb); 38 | add(bookidtxt); 39 | add(readeridlb); 40 | add(readeridtxt); 41 | add(querybtn); 42 | int lx = 50, ly = 90, i = 0, k = 0; 43 | for (int j = 0; j < alloption.length; j++) { 44 | if (lx > 300) { 45 | lx = 50; 46 | ly = ly + 30; 47 | } 48 | if (ly == 90 || ly == 210 || ly == 300) { 49 | System.out.println(i);// /太奇怪了 50 | seplabel[i] = new Label(SepLine + sep[i] + SepLine); 51 | seplabel[i].setBounds(20, ly, 440, 20); 52 | add(seplabel[i]); 53 | j--; 54 | k++; 55 | if (k <= 1) { 56 | i = 0; 57 | } 58 | if (k == 2 || k == 3) { 59 | i = 1; 60 | } 61 | if (k == 4) { 62 | i = 2; 63 | } 64 | } else { 65 | alloption[j] = new Label(optionname[j]); 66 | showoption[j] = new Label(""); 67 | alloption[j].setBounds(lx, ly, 70, 20); 68 | showoption[j].setBounds(lx + 70, ly, 150, 20); 69 | add(alloption[j]); 70 | add(showoption[j]); 71 | } 72 | lx = lx + 250; 73 | } 74 | borrowbtn.setBounds(110, 400, 50, 20); 75 | closebtn.setBounds(310, 400, 50, 20); 76 | add(borrowbtn); 77 | add(closebtn); 78 | borrowbtn.setEnabled(false); 79 | addWindowListener(new WindowAdapter() { 80 | public void windowClosing(WindowEvent e) { 81 | dispose(); 82 | //System.exit(0); 83 | } 84 | }); 85 | querybtn.addActionListener(new ActionListener() { 86 | public void actionPerformed(ActionEvent e) { 87 | queryActionPerformed(e); 88 | } 89 | }); 90 | 91 | borrowbtn.addActionListener(new ActionListener() { 92 | public void actionPerformed(ActionEvent e) { 93 | borrowActionPerformed(e); 94 | } 95 | }); 96 | closebtn.addActionListener(new ActionListener() { 97 | public void actionPerformed(ActionEvent e) { 98 | setInitialize(); 99 | } 100 | }); 101 | 102 | setLocationRelativeTo(null); 103 | setVisible(true); 104 | } 105 | public void borrowActionPerformed(ActionEvent e) { 106 | String bookid = bookidtxt.getText(), readerid = readeridtxt.getText(); 107 | if (!bookid.equals("") && !readerid.equals("")) { 108 | Date currentdate = new Date(); 109 | String borrowbackdate = showoption[12].getText(); 110 | String sql = "update borrow set back_date='"+borrowbackdate+"',if_back='是'"; 111 | sql=sql+"where book_id='"+bookid+"'and reader_id='"+readerid+"'and if_back='否'"; 112 | String sql1 = "update book set stock='" 113 | + (Integer.parseInt(showoption[5].getText()) + 1) + "'" 114 | + "where id='" + bookid + "'"; 115 | int success = DbOp.executeUpdate(sql); 116 | if (success == 1) { 117 | DbOp.executeUpdate(sql1); 118 | JOptionPane.showMessageDialog(null, "还书成功"); 119 | 120 | } else { 121 | JOptionPane.showMessageDialog(null, "还书数据登记失败!"); 122 | } 123 | setInitialize(); 124 | } 125 | } 126 | 127 | public void queryActionPerformed(ActionEvent e) { 128 | String bookid = bookidtxt.getText(), readerid = readeridtxt.getText(); 129 | if (!bookid.equals("") && !readerid.equals("")) { 130 | } else { 131 | JOptionPane.showMessageDialog(null, "图书编号和读者编号都不可以为空"); 132 | setInitialize(); 133 | return; 134 | } 135 | Book book = BookSelect.SelectBookByID(bookid); 136 | Reader reader = ReaderSelect.SelectReaderByID(readerid); 137 | if (!IfBorrowBack.findBook(bookid, readerid)) { 138 | JOptionPane.showMessageDialog(null,"查询不到该读者借阅这本书"); 139 | setInitialize(); 140 | return; 141 | 142 | } else { 143 | 144 | } 145 | if (book != null && reader != null) { 146 | showoption[0].setText(book.getBookname().toString()); 147 | showoption[1].setText(book.getAuthor().toString()); 148 | showoption[2].setText(book.getPublisher().toString()); 149 | showoption[3].setText(book.getPublish_time().toString()); 150 | showoption[4].setText(String.valueOf(book.getPrice())); 151 | showoption[5].setText(String.valueOf(book.getStock())); 152 | showoption[6].setText(reader.getReadername()); 153 | showoption[7].setText(reader.getReadertype()); 154 | showoption[8].setText(String.valueOf(reader.getMax_num())); 155 | showoption[9].setText(String.valueOf(reader.getDays_num())); 156 | } else { 157 | JOptionPane.showMessageDialog(null, "不存在该图书或该读者"); 158 | setInitialize(); 159 | return; 160 | 161 | } 162 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 163 | Date currentdate = new Date(); 164 | Date thisbookborrowdate=getBorrowDate(bookid,readerid); 165 | String daycutearlyday=getReaderBorrowDays(thisbookborrowdate,currentdate); 166 | showoption[10].setText(sdf.format(thisbookborrowdate)); 167 | showoption[12].setText(sdf.format(currentdate)); 168 | showoption[11].setText(daycutearlyday); 169 | borrowbtn.setEnabled(true); 170 | bookidtxt.setEditable(false); 171 | readeridtxt.setEditable(false); 172 | } 173 | public boolean IfLeapYear(int year) {// 是否闰年,用于计算时间差 174 | if (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) { 175 | return true; 176 | } 177 | return false; 178 | } 179 | 180 | public String getReaderBorrowDays(Date date1, Date date2) {// 计算时间差 181 | String sum = ""; 182 | int year1 = 0, month1 = 0, day1 = 0; 183 | int year2 = 0, month2 = 0, day2 = 0; 184 | int[] monthdays = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 185 | Calendar cal1 = new GregorianCalendar(); 186 | Calendar cal2 = new GregorianCalendar(); 187 | cal1.setTime(date1); 188 | year1 = cal1.get(Calendar.YEAR); 189 | month1 = cal1.get(Calendar.MONTH); 190 | day1 = cal1.get(Calendar.DAY_OF_MONTH); 191 | cal2.setTime(date2); 192 | year2 = cal2.get(Calendar.YEAR); 193 | month2 = cal2.get(Calendar.MONTH); 194 | day2 = cal2.get(Calendar.DAY_OF_MONTH); 195 | if (IfLeapYear(year1)) { 196 | monthdays[1] = 29; 197 | } else { 198 | monthdays[1] = 28; 199 | } 200 | int a = 3, count = 0; 201 | while (a > 0) { 202 | if (month1 > monthdays.length - 1) { 203 | year1++; 204 | month1 = 0; 205 | } 206 | if (IfLeapYear(year1)) { 207 | monthdays[1] = 29; 208 | } else { 209 | monthdays[1] = 28; 210 | } 211 | if (day1 > monthdays[month1]) { 212 | month1++; 213 | day1 = 1; 214 | } 215 | day1++; 216 | count++; 217 | if (year1 >= year2 && month1 >= month2 && day1 >= day2) { 218 | a = -1; 219 | 220 | } 221 | } 222 | sum = String.valueOf(count); 223 | return sum; 224 | } 225 | public Date getBorrowDate(String bookid, String readerid) {// 获取读者借书日期 226 | String sql, mydate = ""; 227 | Date readerdate = new Date(); 228 | sql = "select * from borrow where book_id='" + bookid 229 | + "' and reader_id='" + readerid + "' and if_back='否'"; 230 | ResultSet rs = DbOp.executeQuery(sql); 231 | try { 232 | if (rs.next()) { 233 | mydate = rs.getString("borrow_date"); 234 | } 235 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 236 | readerdate = sdf.parse(mydate); 237 | DbOp.close(); 238 | } catch (SQLException e) { 239 | JOptionPane.showMessageDialog(null, "借书日期查询失败"); 240 | } catch (ParseException e2) { 241 | JOptionPane.showMessageDialog(null, "借书日期异常"); 242 | } 243 | return readerdate; 244 | } 245 | 246 | public void setInitialize() { 247 | for (int i = 0; i < showoption.length; i++) { 248 | showoption[i].setText("xxxxx"); 249 | 250 | } 251 | bookidtxt.setText(""); 252 | readeridtxt.setText(""); 253 | bookidtxt.setEditable(true); 254 | readeridtxt.setEditable(true); 255 | borrowbtn.setEnabled(false); 256 | } 257 | 258 | public static void main(String[] args){ 259 | new Back(); 260 | } 261 | } 262 | -------------------------------------------------------------------------------- /Back.java.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/Back.java.java -------------------------------------------------------------------------------- /Book.java: -------------------------------------------------------------------------------- 1 | //Book.java; 2 | //package PublicModule; 3 | import java.sql.Date; 4 | public class Book { 5 | private static String id,bookname,booktype,author,translator,publisher; 6 | private static Date publish_time; 7 | private static int stock,page; 8 | private static float price; 9 | public static String getId() { 10 | return id; 11 | } 12 | public static void setId(String id) { 13 | Book.id = id; 14 | } 15 | public static String getBookname() { 16 | return bookname; 17 | } 18 | public static void setBookname(String bookname) { 19 | Book.bookname = bookname; 20 | } 21 | public static String getBooktype() { 22 | return booktype; 23 | } 24 | public static void setBooktype(String booktype) { 25 | Book.booktype = booktype; 26 | } 27 | public static String getAuthor() { 28 | return author; 29 | } 30 | public static void setAuthor(String author) { 31 | Book.author = author; 32 | } 33 | public static String getTranslator() { 34 | return translator; 35 | } 36 | public static void setTranslator(String translator) { 37 | Book.translator = translator; 38 | } 39 | public static String getPublisher() { 40 | return publisher; 41 | } 42 | public static void setPublisher(String publisher) { 43 | Book.publisher = publisher; 44 | } 45 | public static Date getPublish_time() { 46 | return publish_time; 47 | } 48 | public static void setPublish_time(Date publish_time) { 49 | Book.publish_time = publish_time; 50 | } 51 | public static int getStock() { 52 | return stock; 53 | } 54 | public static void setStock(int stock) { 55 | Book.stock = stock; 56 | } 57 | public static int getPage() { 58 | return page; 59 | } 60 | public static void setPage(int page) { 61 | Book.page = page; 62 | } 63 | public static float getPrice() { 64 | return price; 65 | } 66 | public static void setPrice(float price) { 67 | Book.price = price; 68 | } 69 | public static String[] getBookinformation() { 70 | String[] bookinformation={id,bookname,String.valueOf(page),author,translator,publisher,publish_time.toString(),String.valueOf(price),String.valueOf(stock),booktype,}; 71 | return bookinformation; 72 | } 73 | } -------------------------------------------------------------------------------- /BookAdd.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/BookAdd.java -------------------------------------------------------------------------------- /BookDelete.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/BookDelete.java -------------------------------------------------------------------------------- /BookQuery.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/BookQuery.java -------------------------------------------------------------------------------- /BookQueryImprove.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/BookQueryImprove.java -------------------------------------------------------------------------------- /BookSelect.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/BookSelect.java -------------------------------------------------------------------------------- /BookUpdate.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/BookUpdate.java -------------------------------------------------------------------------------- /Borrow.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/Borrow.java -------------------------------------------------------------------------------- /ChangePassWord.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/ChangePassWord.java -------------------------------------------------------------------------------- /DbOp.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/DbOp.java -------------------------------------------------------------------------------- /GlobalVar.java: -------------------------------------------------------------------------------- 1 | //GlobalVar.java 2 | public class GlobalVar{ 3 | public static String login_user; 4 | } -------------------------------------------------------------------------------- /IfBorrowBack.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/IfBorrowBack.java -------------------------------------------------------------------------------- /Login.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/Login.java -------------------------------------------------------------------------------- /Reader.java: -------------------------------------------------------------------------------- 1 | //package PublicModule; 2 | //Reader.java 3 | public class Reader { 4 | private static String id,readername,readertype,readersex; 5 | private static int max_num,days_num; 6 | public String[] getReaderInformation(){ 7 | String[] infor={id,readername,readertype,readersex,String.valueOf(max_num),String.valueOf(days_num)}; 8 | return infor; 9 | } 10 | public String getId() { 11 | return id; 12 | } 13 | public void setId(String id) { 14 | this.id = id; 15 | } 16 | public String getReadername() { 17 | return readername; 18 | } 19 | public void setReadername(String readername) { 20 | this.readername = readername; 21 | } 22 | public String getReadertype() { 23 | return readertype; 24 | } 25 | public void setReadertype(String readertype) { 26 | this.readertype = readertype; 27 | } 28 | public String getReaderSex() { 29 | return readersex; 30 | } 31 | public void setReaderSex(String sex) { 32 | this.readersex = sex; 33 | } 34 | public int getMax_num() { 35 | return max_num; 36 | } 37 | public void setMax_num(int max_num) { 38 | this.max_num = max_num; 39 | } 40 | public int getDays_num() { 41 | return days_num; 42 | } 43 | public void setDays_num(int days_num) { 44 | this.days_num = days_num; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ReaderAdd.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/ReaderAdd.java -------------------------------------------------------------------------------- /ReaderDelete.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/ReaderDelete.java -------------------------------------------------------------------------------- /ReaderQuery.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/ReaderQuery.java -------------------------------------------------------------------------------- /ReaderSelect.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/ReaderSelect.java -------------------------------------------------------------------------------- /ReaderUpdate.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/ReaderUpdate.java -------------------------------------------------------------------------------- /ShowMain.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/ShowMain.java -------------------------------------------------------------------------------- /Untitled-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/Untitled-4.png -------------------------------------------------------------------------------- /bookbk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/bookbk.png -------------------------------------------------------------------------------- /bookdb.sql: -------------------------------------------------------------------------------- 1 | create database bookdb; 2 | use bookdb; 3 | CREATE TABLE book ( 4 | id CHAR(30) NOT NULL, 5 | bookname VARCHAR(200), 6 | booktype CHAR(30) NOT NULL, 7 | author CHAR(40)NOT NULL, 8 | translator CHAR(40), 9 | publisher VARCHAR(200), 10 | publish_time DATE, 11 | price FLOAT NOT NULL, 12 | stock int not null, 13 | page int not null, 14 | primary key(id) 15 | ); 16 | 17 | CREATE TABLE borrow( 18 | id CHAR(30) NOT NULL, 19 | book_id CHAR(40) NOT NULL, 20 | reader_id CHAR(40) NOT NULL, 21 | borrow_date DATE, 22 | back_date DATE, 23 | if_back CHAR(20) NOT NULL, 24 | primary key(id) 25 | ); 26 | DROP database reader 27 | CREATE TABLE reader( 28 | id CHAR(40) NOT NULL, 29 | readername CHAR(80) NOT NULL, 30 | readertype CHAR(40) NOT NULL, 31 | sex CHAR(20) NOT NULL, 32 | max_num int NOT NULL, 33 | days_num int NOT NULL, 34 | PRIMARY KEY(ID) 35 | ); 36 | 37 | CREATE TABLE user( 38 | id INT NOT NULL AUTO_INCREMENT, 39 | username VARCHAR(80) NOT NULL, 40 | password VARCHAR(80) NOT NULL, 41 | is_admin CHAR(20) NOT NULL, 42 | PRIMARY KEY(id) 43 | ); 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /dir.cmd: -------------------------------------------------------------------------------- 1 | E: 2 | cd\MYJAVA\Chapter11\BookSystem\MainPro 3 | dir * png >dir.java 4 | dir.java -------------------------------------------------------------------------------- /dir.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/dir.txt -------------------------------------------------------------------------------- /login.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/login.png -------------------------------------------------------------------------------- /mainbk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/mainbk.png -------------------------------------------------------------------------------- /querybk.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/querybk.png -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | #### 登录信息 2 | - 超级管理员(用户名:admin 密码:123) 3 | - 运行前确定你已经成功的安装32位java和配置Access数据源 4 | 5 | #### 登陆成功界面 6 | ![](https://github.com/uboger/images/blob/master/image/loginin/lbm.gif) 7 | 8 | #### 运行环境 9 | - JDK(32位jdk) access是只支持32位(x86)所以必须在32位jdk下运行 10 | - windows mac linux .... 11 | - 数据库(access数据库) 12 | - 使用jdk1.5_x 13 | 14 | 15 | #### 使用技术 16 | - Java awt 非 swing 17 | - access 数据库 18 | - 数据库驱动 sun.jdbc.odbc.JdbcOdbcDriver 19 | 20 | #### 连接数据库代码 21 | - 从access数据库连接代码可以看出access数据库毫无安全可言 22 | ```java 23 | public class DbOp{ 24 | private static String driver="sun.jdbc.odbc.JdbcOdbcDriver"; 25 | /** 26 | *jdbc:odbc:bookdb"; 27 | *数据库名称是 bookdb 28 | * 29 | **/ 30 | private static String url="jdbc:odbc:bookdb"; 31 | private static Connection con=null; 32 | private DbOp(){ 33 | try{ 34 | if(con==null){ 35 | Class.forName(driver); 36 | con=DriverManager.getConnection(url); 37 | } 38 | }catch(Exception e){ 39 | JOptionPane.showMessageDialog(null,"数据库未能打开!"); 40 | System.out.println(e.getMessage()); 41 | } 42 | } 43 | ``` 44 | 45 | #### 入口类 46 | - Login.java 点击登陆按钮的代码 47 | ```java 48 | public void sureActionListener(ActionEvent le){ 49 | String user=text_user.getText();//从文本框得到输入的用户名和密码 50 | String pass=text_pass.getText(); 51 | String is_admin=""; 52 | if(user.equals("")||pass.equals("")){ 53 | JOptionPane.showMessageDialog(null,"密码不能为空,请输入密码"); 54 | return; 55 | } 56 | try{ 57 | /** 58 | *数据库核对密码是否正确,正确就登陆成功 59 | * 60 | */ 61 | String sql="select * from user where username="+"'"+user+"'"+"and password="+"'"+pass+"'"; 62 | ResultSet rs=DbOp.executeQuery(sql); 63 | if(rs.next()){ 64 | is_admin=rs.getString("is_admin"); 65 | }else{ 66 | JOptionPane.showMessageDialog(null,"Wrong that is UserNmae or Password "); 67 | return; 68 | } 69 | GlobalVar.login_user=user; 70 | ShowMain show=new ShowMain(); 71 | show.setRights(is_admin); 72 | System.out.println("Successed"); 73 | dispose(); 74 | }catch(SQLException e){ 75 | JOptionPane.showMessageDialog(null,"the wrong from information"); 76 | } 77 | } 78 | ``` 79 | #### access 数据源配置 80 | - 将uboger/LibraryManager下的“图书管理.mdb” 下载到本地电脑 81 | - 建议不要放在有中文名的路径下 82 | - 下载方法略过 83 | - 打开>控制面板>所有控制面板项>管理工具>ODBC数据源(32位)进行数据源配置 84 | - ![](https://github.com/uboger/images/blob/master/image/access/00.png) 85 | - 用户DNS>添加>选择 Driver do Microsoft Access(*.mdb)项 86 | - ![](https://github.com/uboger/images/blob/master/image/access/1.png) 87 | - 88 | - ![](https://github.com/uboger/images/blob/master/image/access/2.png) 89 | - 对话框填写数据源名为 “bookdb” 90 | - ![](https://github.com/uboger/images/blob/master/image/access/4.png) 91 | - 选择“图书管理.mdb”作为数据源>确定>确定>确定 92 | - ![](https://github.com/uboger/images/blob/master/image/access/5.png) 93 | - ![](https://github.com/uboger/images/blob/master/image/access/6.png) 94 | 95 | #### 32位JDK及配置(注意:64位操作系统支持32位JDK,而32位操作系统不支持64位JDK安装) 96 | - [oracle官网下载](http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html"@oracle")jdk-8u181-windows-i586.exe 97 | - [百度网盘下载java8](https://pan.baidu.com/s/1qBPDtTaIY_IXTsWHck2ZIQ@猪侯美人戏)jdk-8u181-windows-i586.exe 98 | - [百度网盘下载java7](https://pan.baidu.com/s/1O0a35pjyUvM7ppgGkBl97w@猪侯美人戏)jdk-7u60-windows-i586.exe 99 | - [百度网盘下载java6](https://pan.baidu.com/s/1K4gaAjtwqZ22mguqfr97YQ@猪侯美人戏)jdk-6u13-windows-i586-p.exe 100 | - [百度网盘下载java5](https://pan.baidu.com/s/1mold9T3rzu9nQiLNGt8KbQ@猪侯美人戏)jdk-1_5_0_04-windows-i586-p.exe 101 | - 在环境变量path加入“D:\Program Files (x86)\Java\jdk1.8.0_181\bin” 102 | - 打开>计算机>属性>高级系统设置>环境变量>path>编辑加入变量值D:\Program Files (x86)\Java\jdk1.8.0_181\bin 103 | - 以管理员打开CMD命令行 104 | - 输入 Java -version 测试Java是否安装成功 105 | - 接着输入 javac 和 java 如果后面有出现内容说明Java安装成功 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /start.bat: -------------------------------------------------------------------------------- 1 | 2 | javac GlobalVar.java 3 | javac ShowMain.java 4 | javac Login.java 5 | java Login 6 | pause 7 | -------------------------------------------------------------------------------- /图书管理 .mdb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/uboger/LibraryManager/d20eaef005395bbc1de9eede6995a3269ee13965/图书管理 .mdb --------------------------------------------------------------------------------