📄 yuding.java~9~
字号:
package untitled5;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;import java.io.*;import java.net.*;import java.sql.*;import java.lang.*;import javax.sql.*;import java.awt.*;import java.awt.event.*;import javax.swing.*;import com.borland.jbcl.layout.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 *///完成预定功能public class yuding extends JFrame { JPanel contentPane; JLabel jLabel1 = new JLabel(); XYLayout xYLayout1 = new XYLayout(); JLabel jLabel2 = new JLabel(); JLabel jLabel3 = new JLabel(); JLabel jLabel4 = new JLabel(); JLabel jLabel6 = new JLabel(); JLabel jLabel5 = new JLabel(); JLabel jLabel7 = new JLabel(); JTextField name = new JTextField(); JLabel jLabel8 = new JLabel(); JPasswordField jPasswordField1 = new JPasswordField(); JLabel jLabel9 = new JLabel(); JTextField issn = new JTextField(); //Construct the frame public yuding() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit() throws Exception { contentPane = (JPanel) this.getContentPane(); jLabel1.setFont(new java.awt.Font("SansSerif", 0, 20)); jLabel1.setForeground(Color.red); jLabel1.setText("图书管理系统"); contentPane.setLayout(xYLayout1); this.setSize(new Dimension(600, 500)); this.setTitle("Frame Title"); this.addHierarchyBoundsListener(new yuding_this_hierarchyBoundsAdapter(this)); jLabel2.setText("晴输入你的姓名和密码"); jLabel2.setFont(new java.awt.Font("SansSerif", 0, 15)); jLabel2.setText("请输入您的姓名和密码"); jLabel3.setFont(new java.awt.Font("SansSerif", 0, 15)); jLabel3.setText("如果有任何不清楚的,请向管理"); jLabel4.setFont(new java.awt.Font("SansSerif", 0, 15)); jLabel4.setText("员询问!!!"); jLabel6.setFont(new java.awt.Font("SansSerif", 0, 15)); jLabel6.setText("和您要预定的书的"); jLabel5.setFont(new java.awt.Font("SansSerif", 0, 15)); jLabel5.setText("ISSN!!!"); jLabel7.setFont(new java.awt.Font("SansSerif", 0, 15)); jLabel7.setText("姓名"); name.setText(""); jLabel8.setFont(new java.awt.Font("SansSerif", 0, 15)); jLabel8.setText("密码"); jPasswordField1.addActionListener(new yuding_jPasswordField1_actionAdapter(this)); jLabel9.setFont(new java.awt.Font("SansSerif", 0, 15)); jLabel9.setText("ISSN:"); issn.setText(""); issn.addActionListener(new yuding_issn_actionAdapter(this)); contentPane.add(jLabel1, new XYConstraints(245, 2, 126, -1)); contentPane.add(jLabel2, new XYConstraints(87, 49, 169, 30)); contentPane.add(jLabel6, new XYConstraints(87, 70, 138, 32)); contentPane.add(jLabel5, new XYConstraints(90, 94, 99, -1)); contentPane.add(jLabel3, new XYConstraints(342, 46, 218, 30)); contentPane.add(jLabel4, new XYConstraints(344, 64, 81, 36)); contentPane.add(jLabel7, new XYConstraints(88, 148, 31, 36)); contentPane.add(name, new XYConstraints(115, 153, 80, 31)); contentPane.add(jLabel8, new XYConstraints(195, 153, -1, 26)); contentPane.add(jPasswordField1, new XYConstraints(224, 152, 84, 32)); contentPane.add(jLabel9, new XYConstraints(89, 216, 51, 36)); contentPane.add(issn, new XYConstraints(129, 222, 97, 32)); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } void jPasswordField1_actionPerformed(ActionEvent e) { } void issn_actionPerformed(ActionEvent e) { validID(); } void validID() { System.out.println("JLKJLJLJLJL"); try { String str1; str1 = issn.getText(); int number=Integer.parseInt(str1); // int issn=Integer.parseInt(str1); System.out.println(str1); // str2 = jPasswordField1.getText(); // System.out.println(str1); //System.out.println(str2); //装载jdbc驱动程序 String driverName = "oracle.jdbc.OracleDriver"; Driver driver = (Driver) Class.forName(driverName).newInstance(); //连接数据库 Connection con = DriverManager.getConnection( "jdbc:oracle:thin:@thsspc0791:1521:tongfang", "sa", "tongfang"); PreparedStatement pstmt = con.prepareStatement( " update book set yuding='yes' where issn=? "); pstmt.setString(1, str1); ResultSet res = pstmt.executeQuery(); System.out.println("ljljljljljljlj"); //String sa=res.getString(1); if ((!res.next()) || res.getString("writer")== null) { JOptionPane.showMessageDialog(this, "查无此书", "错误", JOptionPane.ERROR_MESSAGE); }else { String outputarea=" name " +" writer "+" issn "+" state "+" place "+" date "+" id "+" yuding "+"\n"; //System.out.println("aksdjflkajsdlf"); do{ //System.out.println(res.getString(1)+":" + res.getLong(2) + ":" +res.getLong(3) +":"+res.getInt(4)+":"+res.getString(5)+":"+res.getString(6)+":"+res.getInt(7)); outputarea+=" "+res.getString(1)+" "+" "+res.getString(2)+" "+" "+res.getLong(3)+" "+" "+res.getString(4)+" "+" "+res.getString(5)+" "+" "+res.getDate(6)+" "+" "+res.getInt(7)+" "+" "+res.getString(8)+" "+"\n"; issn.setText(outputarea); }while (res.next()); } pstmt.close(); con.close(); }catch (InstantiationException e) { System.out.println(e.getMessage()); }catch (IllegalAccessException e) { System.out.println(e.getMessage()); }catch (ClassNotFoundException e) { System.out.println(e.getMessage()); }catch (SQLException edd) { edd.printStackTrace() ; System.out.println(edd.getMessage()); } } void this_ancestorMoved(HierarchyEvent e) { }}class yuding_jPasswordField1_actionAdapter implements java.awt.event.ActionListener { yuding adaptee; yuding_jPasswordField1_actionAdapter(yuding adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jPasswordField1_actionPerformed(e); }}class yuding_issn_actionAdapter implements java.awt.event.ActionListener { yuding adaptee; yuding_issn_actionAdapter(yuding adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.issn_actionPerformed(e); }}class yuding_this_hierarchyBoundsAdapter extends java.awt.event.HierarchyBoundsAdapter { yuding adaptee; yuding_this_hierarchyBoundsAdapter(yuding adaptee) { this.adaptee = adaptee; } public void ancestorMoved(HierarchyEvent e) { adaptee.this_ancestorMoved(e); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -