?? educesql.java
字號(hào):
package gongju;import java.awt.BorderLayout;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.awt.event.FocusAdapter;import java.awt.event.FocusEvent;import java.awt.event.KeyAdapter;import java.awt.event.KeyEvent;import java.awt.event.WindowAdapter;import java.awt.event.WindowEvent;import java.io.BufferedReader;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.sql.Connection;import java.sql.DriverManager;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.SQLException;import java.util.Vector;import javax.swing.JButton;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JScrollPane;import javax.swing.JTextArea;import javax.swing.JTextField;import javax.swing.JTextPane;import javax.swing.WindowConstants;/** * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI * Builder, which is free for non-commercial use. If Jigloo is being used * commercially (ie, by a corporation, company or business for any purpose * whatever) then you should purchase a license for each developer using Jigloo. * Please visit www.cloudgarden.com for details. Use of Jigloo implies * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR * ANY CORPORATE OR COMMERCIAL PURPOSE. */// 方便導(dǎo)出sql以便在不同的主機(jī)間導(dǎo)出資料public class Educesql extends javax.swing.JFrame { private JPanel jPanel1; private JTextArea txtMsg; private JButton btnEDUCE; private JLabel labTABLE; private JTextField txtTABLE; // private final String sql_column_name = "select distinct column_name from // all_tab_cols where table_name=?"; // 防止有多個(gè)用戶(hù)下的表列不同而會(huì)報(bào)出“列名無(wú)效”的錯(cuò),修改為取當(dāng)前用戶(hù)下表的列 private final String sql_column_name = "select distinct column_name from user_tab_cols where table_name=?"; private String str_table = ""; private Vector vec_column_name; private StringBuffer errmsg = new StringBuffer(); private String username; private String password; private String host; private String port; private String sid; private String temp_username; private String temp_password; private String temp_host; private String temp_port; private String temp_sid; private JLabel labHost; private JTextField txtHost; private JButton btnTest; private JScrollPane jScrollPane2; private JTextPane txtCondition; private JLabel labCondition; private JTextField txtPort; private JLabel labPort; private JTextField txtSid; private JLabel labSid; private JButton btnView; private JScrollPane jScrollPane1; private JTextField txtPassword; private JLabel labPassword; private JTextField txtUsername; private JLabel labUsername; private Connection con = null; private String before = ""; private String after = ""; private FileOutputStream fostream; private BufferedReader input; private String filepath; private String condition; private int checkcondition = 0; private boolean checkcon = true; private JPanel panTime; private int checkconn = 0; PreparedStatement ps_column = null; private Showtime showtime; /** * Auto-generated main method to display this JFrame */ public static void main(String[] args) { Educesql inst = new Educesql(); inst.setVisible(true); } public Educesql() { super("Educesql"); initGUI(); Exit(); } private void initGUI() { try { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); { jPanel1 = new JPanel(); getContentPane().add(jPanel1, BorderLayout.CENTER); jPanel1.setLayout(null); jPanel1.setPreferredSize(new java.awt.Dimension(553, 182)); { txtTABLE = new JTextField(); jPanel1.add(txtTABLE); txtTABLE.setBounds(84, 49, 126, 28); txtTABLE.setFont(new java.awt.Font("Tahoma", 0, 20)); txtTABLE.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent evt) { if (evt.getKeyCode() == 10) { generatesql(); } } }); } { labTABLE = new JLabel(); jPanel1.add(labTABLE); labTABLE.setText("Table"); labTABLE.setBounds(14, 49, 63, 28); } { btnEDUCE = new JButton(); jPanel1.add(btnEDUCE); btnEDUCE.setText("\u5bfc\u51fa"); btnEDUCE.setBounds(224, 91, 63, 28); btnEDUCE.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { generatesql(); } }); } { labUsername = new JLabel(); jPanel1.add(labUsername); labUsername.setText("Username"); labUsername.setBounds(14, 14, 63, 28); } { txtUsername = new JTextField(); jPanel1.add(txtUsername); txtUsername.setBounds(84, 14, 84, 28); txtUsername.setFont(new java.awt.Font("Tahoma", 0, 20)); // txtUsername.addFocusListener(new FocusAdapter() { // public void focusLost(FocusEvent evt) { // after=txtUsername.getText(); // if(before.equalsIgnoreCase(after)) // { // checksame=true; // } // } // public void focusGained(FocusEvent evt) { // before=txtUsername.getText(); // } // }); } { labPassword = new JLabel(); jPanel1.add(labPassword); labPassword.setText("Password"); labPassword.setBounds(182, 14, 63, 28); } { txtPassword = new JTextField(); jPanel1.add(txtPassword); txtPassword.setBounds(245, 14, 84, 28); txtPassword.setFont(new java.awt.Font("Tahoma", 0, 20)); // txtPassword.addFocusListener(new FocusAdapter() { // public void focusLost(FocusEvent evt) { // after=txtPassword.getText(); // if(before.equalsIgnoreCase(after)) // { // checksame=true; // } // } // public void focusGained(FocusEvent evt) { // before=txtPassword.getText(); // } // }); } { jScrollPane1 = new JScrollPane(); jPanel1.add(jScrollPane1); jScrollPane1.setBounds(14, 91, 196, 35); { txtMsg = new JTextArea(); jScrollPane1.setViewportView(txtMsg); txtMsg.setBounds(212, 93, 137, 32); } } { btnView = new JButton(); jPanel1.add(btnView); btnView.setText("\u67e5\u770b"); btnView.setBounds(294, 91, 63, 28); btnView.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { // 打開(kāi)生成的sql Runtime rt = Runtime.getRuntime(); try { rt .exec("CMD /C" + filepath.replace("//", "\\")); txtMsg .append("\n\u6253\u5f00\u6587\u4ef6\u6210\u529f");// 打開(kāi)文件成功 } catch (Exception e) { txtMsg .setText("\n\u6253\u5f00\u6587\u4ef6\u5931\u8d25");// 打開(kāi)文件失敗 rt.gc(); } } }); } { txtHost = new JTextField(); jPanel1.add(txtHost); txtHost.setBounds(420, 14, 119, 28); txtHost.setText("172.21.2.33"); txtHost.setFont(new java.awt.Font("Tahoma", 0, 20)); } { labHost = new JLabel(); jPanel1.add(labHost); labHost.setText("HOST"); labHost.setBounds(371, 14, 49, 28); } { labSid = new JLabel(); jPanel1.add(labSid); labSid.setText("SID"); labSid.setBounds(371, 91, 42, 28); } { txtSid = new JTextField(); jPanel1.add(txtSid); txtSid.setBounds(420, 91, 119, 28); txtSid.setText("fpg100t"); txtSid.setFont(new java.awt.Font("Tahoma", 0, 20)); } { labPort = new JLabel(); jPanel1.add(labPort); labPort.setText("Port"); labPort.setBounds(371, 56, 49, 28); } { txtPort = new JTextField(); jPanel1.add(txtPort); txtPort.setBounds(420, 56, 119, 28); txtPort.setText("1521"); txtPort.setFont(new java.awt.Font("Tahoma", 0, 20)); } { labCondition = new JLabel(); jPanel1.add(labCondition); labCondition.setText("Condition"); labCondition.setBounds(21, 133, 77, 35); } { jScrollPane2 = new JScrollPane(); jPanel1.add(jScrollPane2); jScrollPane2.setBounds(98, 133, 301, 35); { txtCondition = new JTextPane(); jScrollPane2.setViewportView(txtCondition); txtCondition.setBounds(98, 98, 266, 35); txtCondition.setText("只需要輸入條件,前面不用加where"); txtCondition.setFont(new java.awt.Font("宋體", 0, 18)); // txtCondition.setFont(new // java.awt.Font("Tahoma",0,20)); txtCondition.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent evt) { if (checkcondition == 0) { txtCondition.setText("");
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -