📄 unserve.java
字号:
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.*;import javax.swing.event.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2003</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class unserve extends JFrame { JPanel contentPane; JLabel jLabel1 = new JLabel(); XYLayout xYLayout1 = new XYLayout(); JLabel jLabel2 = new JLabel(); JLabel jLabel3 = new JLabel(); JTextField jTextField1 = new JTextField(); JLabel jLabel4 = new JLabel(); JTextField jTextField2 = new JTextField(); JLabel jLabel5 = new JLabel(); JTextField jTextField3 = new JTextField(); JLabel jLabel6 = new JLabel(); JTextField jTextField4 = new JTextField(); JLabel jLabel7 = new JLabel(); JTextField jTextField5 = new JTextField(); JButton jButton1 = new JButton(); //Construct the frame public unserve() { 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, 25)); jLabel1.setForeground(Color.red); jLabel1.setText("物流管理系统"); contentPane.setLayout(xYLayout1); this.setSize(new Dimension(500, 400)); this.setTitle("物流管理系统"); contentPane.setBackground(UIManager.getColor("Desktop.background")); contentPane.setFont(new java.awt.Font("SansSerif", 0, 20)); jLabel2.setFont(new java.awt.Font("SansSerif", 0, 30)); jLabel2.setText("经办人员登记"); jLabel3.setFont(new java.awt.Font("SansSerif", 0, 25)); jLabel3.setText("编 号"); jTextField1.setText(""); jLabel4.setFont(new java.awt.Font("SansSerif", 0, 25)); jLabel4.setText("姓名"); jTextField2.setText(""); jLabel5.setFont(new java.awt.Font("SansSerif", 0, 25)); jLabel5.setText("家庭住址"); jTextField3.setText(""); jLabel6.setFont(new java.awt.Font("SansSerif", 0, 25)); jLabel6.setText("办公电话"); jTextField4.setText(""); jLabel7.setFont(new java.awt.Font("SansSerif", 0, 25)); jLabel7.setText("家庭电话"); jTextField5.setText(""); jButton1.setFont(new java.awt.Font("SansSerif", 0, 25)); jButton1.setText("提交"); jButton1.addActionListener(new unserve_jButton1_actionAdapter(this)); contentPane.add(jLabel1, new XYConstraints(177, 1, 152, 34)); contentPane.add(jLabel2, new XYConstraints(159, 36, -1, -1)); contentPane.add(jTextField1, new XYConstraints(147, 94, 109, 34)); contentPane.add(jLabel4, new XYConstraints(260, 90, -1, -1)); contentPane.add(jTextField2, new XYConstraints(310, 89, 115, 37)); contentPane.add(jLabel3, new XYConstraints(49, 93, -1, -1)); contentPane.add(jLabel5, new XYConstraints(47, 163, 101, -1)); contentPane.add(jTextField3, new XYConstraints(146, 161, 279, 36)); contentPane.add(jLabel6, new XYConstraints(45, 225, -1, -1)); contentPane.add(jTextField4, new XYConstraints(145, 226, 278, 38)); contentPane.add(jLabel7, new XYConstraints(44, 285, -1, -1)); contentPane.add(jTextField5, new XYConstraints(141, 287, 279, 35)); contentPane.add(jButton1, new XYConstraints(222, 335, -1, -1)); } //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 issn_actionPerformed(ActionEvent e) { } void validID() { try { //定义显示的字符串 String str1; String str2; String str3; String str4; String str5; str1 = jTextField1.getText(); str2 = jTextField2.getText(); str3 = jTextField3.getText(); str4 = jTextField4.getText(); str5 = jTextField5.getText(); //装载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( " insert inFactory('facNum','facName','facAdress','telNum','man')values(?,?,?,?,?,?)"); pstmt.setString(1, str1); pstmt.setString(2, str2); pstmt.setString(1, str3); pstmt.setString(4, str4); pstmt.setString(5, str5); ResultSet res = pstmt.executeQuery(); 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 jButton1_actionPerformed(ActionEvent e) { validID(); }}class unserve_jButton1_actionAdapter implements java.awt.event.ActionListener { unserve adaptee; unserve_jButton1_actionAdapter(unserve adaptee) { this.adaptee = adaptee; } public void actionPerformed(ActionEvent e) { adaptee.jButton1_actionPerformed(e); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -