这是Java数据库系统项目开发实践源代码,所有代码经过测试

源代码在线查看: frame3.java~65~

软件大小: 8384 K
上传用户: gdmichael
关键词: Java 数据库系统 实践 代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				package untitled5;				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.*;				public class Frame3 extends JFrame {				  JPanel contentPane;				  XYLayout xYLayout1 = new XYLayout();				  JLabel jLabel1 = new JLabel();				  JLabel jLabel2 = new JLabel();				  JLabel jLabel3 = new JLabel();				  JLabel jLabel4 = new JLabel();				  JLabel jLabel5 = new JLabel();				  JLabel jLabel6 = new JLabel();				  JTextField jTextField1 = new JTextField();				  JTextField jTextField2 = new JTextField();				  JTextField jTextField3 = new JTextField();				  JTextField jTextField4 = new JTextField();				  JButton jButton1 = new JButton();								  //Construct the frame				  public Frame3() {				    enableEvents(AWTEvent.WINDOW_EVENT_MASK);				    try {				      jbInit();				    }				    catch(Exception e) {				      e.printStackTrace();				    }				  }				  //Component initialization				  private void jbInit() throws Exception  {				    contentPane = (JPanel) this.getContentPane();				    contentPane.setLayout(xYLayout1);				    this.setSize(new Dimension(500,500));				    this.setTitle("销售管理系统");				    jLabel1.setFont(new java.awt.Font("SansSerif", 0, 25));				    jLabel1.setForeground(Color.red);				    jLabel1.setText("超市管理系统");				    jLabel2.setFont(new java.awt.Font("SansSerif", 0, 30));				    jLabel2.setRequestFocusEnabled(true);				    jLabel2.setText("小 订 单 登 记");				    jLabel3.setFont(new java.awt.Font("SansSerif", 0, 25));				    jLabel3.setText("订单号");				    jLabel4.setFont(new java.awt.Font("SansSerif", 0, 25));				    jLabel4.setText("数   量");				    jLabel5.setFont(new java.awt.Font("SansSerif", 0, 25));				    jLabel5.setText("产品号");				    jLabel6.setFont(new java.awt.Font("SansSerif", 0, 25));				    jLabel6.setText("总金额");				    jTextField1.setText("");				    jTextField2.setText("");				    jTextField3.setText("");				    jTextField4.setText("");				    jButton1.setFont(new java.awt.Font("SansSerif", 0, 25));				    jButton1.setText("提交");				    contentPane.add(jLabel1,   new XYConstraints(182, 0, 171, 37));				    contentPane.add(jLabel2,  new XYConstraints(166, 27, -1, -1));				    contentPane.add(jLabel3,   new XYConstraints(94, 90, -1, -1));				    contentPane.add(jLabel4,    new XYConstraints(97, 159, -1, -1));				    contentPane.add(jLabel6,    new XYConstraints(94, 292, -1, -1));				    contentPane.add(jTextField1,   new XYConstraints(173, 86, 128, 38));				    contentPane.add(jTextField2,    new XYConstraints(173, 160, 127, 40));				    contentPane.add(jLabel5, new XYConstraints(94, 221, -1, -1));				    contentPane.add(jTextField3,     new XYConstraints(174, 221, 126, 38));				    contentPane.add(jTextField4,    new XYConstraints(174, 291, 125, 40));				    contentPane.add(jButton1,        new XYConstraints(176, 375, 121, 43));				  }				  //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 jTextField1_actionPerformed(ActionEvent e) {				    }				  void Insert() {				   try {				     //定义显示的字符串				     String str1;				     String str2;				     String str3;				     String str4;				    String str5;				     str1 = jTextField1.getText();				     str2 = jTextField2.getText();				     str3 = jTextField3.getText();				     str4 = jTextField4.getText();				     //装载jdbc驱动程序				     String driverName = "oracle.jdbc.OracleDriver";				     Driver driver = (Driver) Class.forName(driverName).newInstance();				     //连接数据库				     Connection con = DriverManager.getConnection(				         "jdbc:oracle:thin:@thsspc0791:1521:liuyong", "sa", "tongfang");				     PreparedStatement pstmt = con.prepareStatement(				         " insert LittlePaper('ID','quality','goodID','MoneyAll')values(?,?,?,?)  ");				    pstmt.setString(1, str1);				    pstmt.setString(2, str2);				    pstmt.setString(1, str3);				    pstmt.setString(4, str4);				     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) {				      Insert();				  }				}							

相关资源