27,579
社区成员
发帖
与我相关
我的任务
分享
public void fuck() {
Connection con;
Statement sta;
ResultSet rs;
String sql_driver;
String sql_url;
sql_driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
sql_url =
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=restaurant";
String user = "sa";
String pwd = "ericulje";
try {
Class.forName(sql_driver);
System.out.println("driver is ok");
con = DriverManager.getConnection(sql_url, user, pwd);
System.out.println("connection is ok");
sta = con.createStatement();
rs = sta.executeQuery("select fangtaiId from fangtaiInfo");
if (rs.next()) {
String str1, str2, str3, str4, str5, str6, str7, str8, str9,
str10;
str1 = rs.getString(1);
str2 = rs.getString(2);
str3 = rs.getString(3);
str4 = rs.getString(4);
str5 = rs.getString(5);
str6 = rs.getString(6);
str7 = rs.getString(7);
str8 = rs.getString(8);
str9 = rs.getString(9);
str10 = rs.getString(10);
String table[] = {"str1", "str2", "str3", "str4", "str5",
"str6", "str7", "str8", "str9", "str10"};
jComboBox1 = new JComboBox(table);
}
con.close();
} catch (Exception e) {
e.printStackTrace(); //printStackTrace();
}
}
package rams;
import java.awt.*;
import javax.swing.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.Dimension;
import java.sql.*;
import java.util.Vector;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class BookService_Frame extends JFrame {
JPanel contentPane;
XYLayout xYLayout1 = new XYLayout();
JTabbedPane jTabbedPane1 = new JTabbedPane();
JPanel jPanel1 = new JPanel();
XYLayout xYLayout2 = new XYLayout();
JPanel jPanel2 = new JPanel();
JPanel jPanel3 = new JPanel();
XYLayout xYLayout3 = new XYLayout();
XYLayout xYLayout4 = new XYLayout();
JTextField jTextField1 = new JTextField();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JComboBox jComboBox1 = new JComboBox();
Connection con;
JLabel jLabel3 = new JLabel();
JComboBox jComboBox2 = new JComboBox();
JLabel jLabel4 = new JLabel();
JTextField jTextField2 = new JTextField();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JLabel jLabel5 = new JLabel();
JTextField jTextField3 = new JTextField();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
public BookService_Frame() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(xYLayout1);
setSize(new Dimension(400, 300));
setTitle("预定服务");
this.setVisible(true);
jPanel1.setLayout(xYLayout2);
jPanel1.setNextFocusableComponent(jPanel2);
jPanel1.setToolTipText("");
jTabbedPane1.setToolTipText("");
jPanel2.setLayout(xYLayout3);
jPanel3.setLayout(xYLayout4);
jLabel1.setText("订单号:");
jLabel2.setText("房台号:");
jComboBox1.setInputVerifier(null);
//String table[]={"Z01","Z02","Z03","Z04","Z05","Z06","Z07","Z08","Z09","Z10"};
//jComboBox1 = new JComboBox(table);
jLabel3.setText("服务员:");
jLabel4.setText("结账金额:");
jButton1.setText("提交");
jButton2.setText("退出");
jLabel5.setText("请输入您要删除订单的订单号:");
jButton3.setText("确定");
jButton4.setText("退出");
contentPane.add(jTabbedPane1, new XYConstraints(2, 7, 398, 305));
jTabbedPane1.add(jPanel1, "增加订单");
jTabbedPane1.add(jPanel2, "已有订单");
jTabbedPane1.add(jPanel3, "取消订单");
jPanel1.add(jLabel1, new XYConstraints(40, 21, 60, 21));
jPanel1.add(jTextField1, new XYConstraints(103, 21, 73, -1));
jPanel1.add(jLabel3, new XYConstraints(204, 23, -1, -1));
jPanel1.add(jComboBox2, new XYConstraints(270, 20, 73, -1));
jPanel1.add(jLabel2, new XYConstraints(204, 102, -1, -1));
jPanel1.add(jComboBox1, new XYConstraints(269, 92, 73, 25));
jPanel1.add(jButton2, new XYConstraints(256, 185, -1, -1));
jPanel1.add(jButton1, new XYConstraints(119, 185, -1, -1));
jPanel1.add(jLabel4, new XYConstraints(40, 96, 62, 21));
jPanel1.add(jTextField2, new XYConstraints(104, 95, 73, 22));
jPanel3.add(jLabel5, new XYConstraints(17, 50, 190, 36));
jPanel3.add(jTextField3, new XYConstraints(208, 57, 69, 25));
jPanel3.add(jButton3, new XYConstraints(92, 183, -1, -1));
jPanel3.add(jButton4, new XYConstraints(233, 182, -1, -1));
jTabbedPane1.setSelectedComponent(jPanel1);
fuck();
}
public void fuck() {
Connection con;
Statement sta;
ResultSet rs;
String sql_driver;
String sql_url;
sql_driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
sql_url =
"jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=restaurant";
String user = "sa";
String pwd = "ericulje";
try {
Class.forName(sql_driver);
System.out.println("driver is ok");
con = DriverManager.getConnection(sql_url, user, pwd);
System.out.println("connection is ok");
sta = con.createStatement();
rs = sta.executeQuery("select fangtaiId from fangtaiInfo");
Vector<String> vec = new Vector<String>();
while (rs.next()) {
String strfangtaiId = rs.getString("fangtaiId");
vec.addElement(strfangtaiId);
}
jComboBox1 = new JComboBox(vec);
con.close();
} catch (Exception e) {
e.printStackTrace(); //printStackTrace();
}
}
}
System.out.println("driver is ok");
con = DriverManager.getConnection(sql_url, user, pwd);
System.out.println("connection is ok");
sta = con.createStatement();
rs = sta.executeQuery("select fangtaiId from fangtaiInfo");
Vector<String> vec=new Vector<String>();
while (rs.next()) {
String strfangtaiId=rs.getString("fangtaiId");
vec.addElement(strfangtaiId);
}
jComboBox1 = new JComboBox(vec);