/** Method declaration Adjust this method for large strings...ie multi megabtypes. */ void execute() { String sCmd = null; if (4096 <= ifHuge.length()) { sCmd = ifHuge; } else { sCmd = txtCommand.getText(); } if (sCmd.startsWith("-->>>TEST<<<--")) { testPerformance(); return; } String g[] = new String[1]; lTime = System.currentTimeMillis(); try { sStatement.execute(sCmd); lTime = System.currentTimeMillis() - lTime; int r = sStatement.getUpdateCount(); if (r == -1) { formatResultSet(sStatement.getResultSet()); } else { g[0] = "update count"; gResult.setHead(g); g[0] = String.valueOf(r); gResult.addRow(g); } addToRecent(txtCommand.getText()); } catch (SQLException e) { lTime = System.currentTimeMillis() - lTime; g[0] = "SQL Error"; gResult.setHead(g); String s = e.getMessage(); s += " / Error Code: " + e.getErrorCode(); s += " / State: " + e.getSQLState(); g[0] = s; gResult.addRow(g); } updateResult(); System.gc(); }
/** Method declaration */ private void initGUI() { Panel pQuery = new Panel(); Panel pCommand = new Panel(); pResult = new Panel(); pQuery.setLayout(new BorderLayout()); pCommand.setLayout(new BorderLayout()); pResult.setLayout(new BorderLayout()); Font fFont = new Font("Dialog", Font.PLAIN, 12); txtCommand = new TextArea(5, 40); txtCommand.addKeyListener(this); txtResult = new TextArea(20, 40); txtCommand.setFont(fFont); txtResult.setFont(new Font("Courier", Font.PLAIN, 12)); butExecute = new Button("Execute"); butClear = new Button("Clear"); butExecute.addActionListener(this); butClear.addActionListener(this); pCommand.add("East", butExecute); pCommand.add("West", butClear); pCommand.add("Center", txtCommand); gResult = new Grid(); setLayout(new BorderLayout()); pResult.add("Center", gResult); pQuery.add("North", pCommand); pQuery.add("Center", pResult); fMain.add("Center", pQuery); tTree = new Tree(); // (ulrivo): screen with less than 640 width Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); if (d.width >= 640) { tTree.setMinimumSize(new Dimension(200, 100)); } else { tTree.setMinimumSize(new Dimension(80, 100)); } gResult.setMinimumSize(new Dimension(200, 300)); fMain.add("West", tTree); doLayout(); fMain.pack(); }
/** * Method declaration * * @param s * @param help */ void showHelp(String help[]) { txtCommand.setText(help[0]); txtResult.setText(help[1]); bHelp = true; pResult.removeAll(); pResult.add("Center", txtResult); pResult.doLayout(); txtCommand.requestFocus(); txtCommand.setCaretPosition(help[0].length()); }
/** Method declaration */ void updateResult() { if (iResult == 0) { // in case 'help' has removed the grid if (bHelp) { pResult.removeAll(); pResult.add("Center", gResult); pResult.doLayout(); bHelp = false; } gResult.update(); gResult.repaint(); } else { showResultInText(); } txtCommand.selectAll(); txtCommand.requestFocus(); }
public void actionPerformed(ActionEvent e) { JButton b = (JButton) e.getSource(); if (b == bu) { j14 = new JLabel("NEW IMAGE"); j14.setBounds(840, 200, 300, 300); q.add(j14); JFileChooser filechooser = new JFileChooser(); int result = filechooser.showOpenDialog(this); f = filechooser.getSelectedFile(); try { String dir1 = f.getAbsolutePath(); // setText(dir); str = dir1; // ResizeImage.resize(dir); f = new File(dir1); } catch (Exception e1) { } repaint(); // b=(JButton)e.getSource(); } if (b == ba) { try { read(); patient.add(tadd.getText(), tsym.getText(), f, str); JOptionPane.showMessageDialog(null, "Patient ID: " + patient.pid + " Record Added"); } catch (Exception e4) { System.out.println("" + e4); } } if (b == bm) { try { setVisible(false); } catch (Exception e4) { System.out.println("" + e4); } } }
/** Method declaration */ void insertTestData() { try { DatabaseManagerCommon.createTestTables(sStatement); refreshTree(); txtCommand.setText(DatabaseManagerCommon.createTestData(sStatement)); refreshTree(); for (int i = 0; i < DatabaseManagerCommon.testDataSql.length; i++) { addToRecent(DatabaseManagerCommon.testDataSql[i]); } execute(); } catch (SQLException e) { e.printStackTrace(); } }
/** Method declaration */ void showResultInText() { String col[] = gResult.getHead(); int width = col.length; int size[] = new int[width]; Vector data = gResult.getData(); String row[]; int height = data.size(); for (int i = 0; i < width; i++) { size[i] = col[i].length(); } for (int i = 0; i < height; i++) { row = (String[]) data.elementAt(i); for (int j = 0; j < width; j++) { int l = row[j].length(); if (l > size[j]) { size[j] = l; } } } StringBuffer b = new StringBuffer(); for (int i = 0; i < width; i++) { b.append(col[i]); for (int l = col[i].length(); l <= size[i]; l++) { b.append(' '); } } b.append(NL); for (int i = 0; i < width; i++) { for (int l = 0; l < size[i]; l++) { b.append('-'); } b.append(' '); } b.append(NL); for (int i = 0; i < height; i++) { row = (String[]) data.elementAt(i); for (int j = 0; j < width; j++) { b.append(row[j]); for (int l = row[j].length(); l <= size[j]; l++) { b.append(' '); } } b.append(NL); } b.append(NL + height + " row(s) in " + lTime + " ms"); txtResult.setText(b.toString()); }
/** Method declaration */ void testPerformance() { String all = txtCommand.getText(); StringBuffer b = new StringBuffer(); long total = 0; for (int i = 0; i < all.length(); i++) { char c = all.charAt(i); if (c != '\n') { b.append(c); } } all = b.toString(); String g[] = new String[4]; g[0] = "ms"; g[1] = "count"; g[2] = "sql"; g[3] = "error"; gResult.setHead(g); int max = 1; lTime = System.currentTimeMillis() - lTime; while (!all.equals("")) { int i = all.indexOf(';'); String sql; if (i != -1) { sql = all.substring(0, i); all = all.substring(i + 1); } else { sql = all; all = ""; } if (sql.startsWith("--#")) { max = Integer.parseInt(sql.substring(3)); continue; } else if (sql.startsWith("--")) { continue; } g[2] = sql; long l = 0; try { l = DatabaseManagerCommon.testStatement(sStatement, sql, max); total += l; g[0] = String.valueOf(l); g[1] = String.valueOf(max); g[3] = ""; } catch (SQLException e) { g[0] = g[1] = "n/a"; g[3] = e.toString(); } gResult.addRow(g); System.out.println(l + " ms : " + sql); } g[0] = "" + total; g[1] = "total"; g[2] = ""; gResult.addRow(g); lTime = System.currentTimeMillis() - lTime; updateResult(); }
/** * Method declaration * * @param ev */ public void actionPerformed(ActionEvent ev) { String s = ev.getActionCommand(); if (s == null) { if (ev.getSource() instanceof MenuItem) { MenuItem i; s = ((MenuItem) ev.getSource()).getLabel(); } } if (s.equals("Execute")) { execute(); } else if (s.equals("Exit")) { windowClosing(null); } else if (s.equals("Transfer")) { Transfer.work(null); } else if (s.equals("Dump")) { Transfer.work(new String[] {"-d"}); /* NB - 26052002 Restore is not implemented yet in the transfer tool */ /* } else if (s.equals("Restore")) { Transfer.work(new String[]{"-r"}); */ } else if (s.equals("Logging on")) { jdbcSystem.setLogToSystem(true); } else if (s.equals("Logging off")) { jdbcSystem.setLogToSystem(false); } else if (s.equals("Refresh Tree")) { refreshTree(); } else if (s.startsWith("#")) { int i = Integer.parseInt(s.substring(1)); txtCommand.setText(sRecent[i]); } else if (s.equals("Connect...")) { connect(ConnectionDialog.createConnection(fMain, "Connect")); refreshTree(); } else if (s.equals("Results in Grid")) { iResult = 0; pResult.removeAll(); pResult.add("Center", gResult); pResult.doLayout(); } else if (s.equals("Open Script...")) { FileDialog f = new FileDialog(fMain, "Open Script", FileDialog.LOAD); // (ulrivo): set default directory if set from command line if (defDirectory != null) { f.setDirectory(defDirectory); } f.show(); String file = f.getFile(); if (file != null) { txtCommand.setText(DatabaseManagerCommon.readFile(f.getDirectory() + file)); } } else if (s.equals("Save Script...")) { FileDialog f = new FileDialog(fMain, "Save Script", FileDialog.SAVE); // (ulrivo): set default directory if set from command line if (defDirectory != null) { f.setDirectory(defDirectory); } f.show(); String file = f.getFile(); if (file != null) { DatabaseManagerCommon.writeFile(f.getDirectory() + file, txtCommand.getText()); } } else if (s.equals("Save Result...")) { FileDialog f = new FileDialog(fMain, "Save Result", FileDialog.SAVE); // (ulrivo): set default directory if set from command line if (defDirectory != null) { f.setDirectory(defDirectory); } f.show(); String file = f.getFile(); if (file != null) { showResultInText(); DatabaseManagerCommon.writeFile(f.getDirectory() + file, txtResult.getText()); } } else if (s.equals("Results in Text")) { iResult = 1; pResult.removeAll(); pResult.add("Center", txtResult); pResult.doLayout(); showResultInText(); } else if (s.equals("AutoCommit on")) { try { cConn.setAutoCommit(true); } catch (SQLException e) { } } else if (s.equals("AutoCommit off")) { try { cConn.setAutoCommit(false); } catch (SQLException e) { } } else if (s.equals("Enlarge Tree")) { Dimension d = tTree.getMinimumSize(); d.width += 20; tTree.setMinimumSize(d); fMain.pack(); } else if (s.equals("Shrink Tree")) { Dimension d = tTree.getMinimumSize(); d.width -= 20; if (d.width >= 0) { tTree.setMinimumSize(d); } fMain.pack(); } else if (s.equals("Enlarge Command")) { txtCommand.setRows(txtCommand.getRows() + 1); fMain.pack(); } else if (s.equals("Shrink Command")) { int i = txtCommand.getRows() - 1; txtCommand.setRows(i < 1 ? 1 : i); fMain.pack(); } else if (s.equals("Commit")) { try { cConn.commit(); } catch (SQLException e) { } } else if (s.equals("Insert test data")) { insertTestData(); } else if (s.equals("Rollback")) { try { cConn.rollback(); } catch (SQLException e) { } } else if (s.equals("Disable MaxRows")) { try { sStatement.setMaxRows(0); } catch (SQLException e) { } } else if (s.equals("Set MaxRows to 100")) { try { sStatement.setMaxRows(100); } catch (SQLException e) { } } else if (s.equals("SELECT")) { showHelp(DatabaseManagerCommon.selectHelp); } else if (s.equals("INSERT")) { showHelp(DatabaseManagerCommon.insertHelp); } else if (s.equals("UPDATE")) { showHelp(DatabaseManagerCommon.updateHelp); } else if (s.equals("DELETE")) { showHelp(DatabaseManagerCommon.deleteHelp); } else if (s.equals("CREATE TABLE")) { showHelp(DatabaseManagerCommon.createTableHelp); } else if (s.equals("DROP TABLE")) { showHelp(DatabaseManagerCommon.dropTableHelp); } else if (s.equals("CREATE INDEX")) { showHelp(DatabaseManagerCommon.createIndexHelp); } else if (s.equals("DROP INDEX")) { showHelp(DatabaseManagerCommon.dropIndexHelp); } else if (s.equals("CHECKPOINT")) { showHelp(DatabaseManagerCommon.checkpointHelp); } else if (s.equals("SCRIPT")) { showHelp(DatabaseManagerCommon.scriptHelp); } else if (s.equals("SHUTDOWN")) { showHelp(DatabaseManagerCommon.shutdownHelp); } else if (s.equals("SET")) { showHelp(DatabaseManagerCommon.setHelp); } else if (s.equals("Test Script")) { showHelp(DatabaseManagerCommon.testHelp); } }
/** Method declaration */ void main() { fMain = new Frame("HSQL Database Manager"); imgEmpty = createImage(new MemoryImageSource(2, 2, new int[4 * 4], 2, 2)); fMain.setIconImage(imgEmpty); fMain.addWindowListener(this); MenuBar bar = new MenuBar(); // used shortcuts: CERGTSIUDOLM String fitems[] = { "-Connect...", "--", "-Open Script...", "-Save Script...", "-Save Result...", "--", "-Exit" }; addMenu(bar, "File", fitems); String vitems[] = { "RRefresh Tree", "--", "GResults in Grid", "TResults in Text", "--", "1Shrink Tree", "2Enlarge Tree", "3Shrink Command", "4Enlarge Command" }; addMenu(bar, "View", vitems); String sitems[] = { "SSELECT", "IINSERT", "UUPDATE", "DDELETE", "--", "-CREATE TABLE", "-DROP TABLE", "-CREATE INDEX", "-DROP INDEX", "--", "-CHECKPOINT", "-SCRIPT", "-SET", "-SHUTDOWN", "--", "-Test Script" }; addMenu(bar, "Command", sitems); Menu recent = new Menu("Recent"); mRecent = new Menu("Recent"); bar.add(mRecent); String soptions[] = { "-AutoCommit on", "-AutoCommit off", "OCommit", "LRollback", "--", "-Disable MaxRows", "-Set MaxRows to 100", "--", "-Logging on", "-Logging off", "--", "-Insert test data" }; addMenu(bar, "Options", soptions); /* NB - 26052002 Restore is not implemented yet in the transfer tool */ String stools[] = {"-Dump", /*"-Restore",*/ "-Transfer"}; addMenu(bar, "Tools", stools); fMain.setMenuBar(bar); fMain.setSize(640, 480); fMain.add("Center", this); initGUI(); sRecent = new String[iMaxRecent]; Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); Dimension size = fMain.getSize(); // (ulrivo): full size on screen with less than 640 width if (d.width >= 640) { fMain.setLocation((d.width - size.width) / 2, (d.height - size.height) / 2); } else { fMain.setLocation(0, 0); fMain.setSize(d); } fMain.show(); // (ulrivo): load query from command line if (defScript != null) { if (defDirectory != null) { defScript = defDirectory + File.separator + defScript; } txtCommand.setText(DatabaseManagerCommon.readFile(defScript)); } txtCommand.requestFocus(); }
public void focusLost(FocusEvent e) { int id = 0; boolean res = false; JTextField t = (JTextField) e.getSource(); if (t == tpid) { try { id = Integer.parseInt(tpid.getText()); res = patient.psearch(id); } catch (Exception e1) { } if (res) { int no, ag = 0, fee = 0; String pfn = "", bg = "", pmn = "", dt1 = "", pln = "", add = "", sym = "", dn = "", dig = "", cn = "", gender = "", wgt = ""; try { dt1 = patient.rs.getString(1); no = patient.rs.getInt(2); pfn = patient.rs.getString(3); pmn = patient.rs.getString(4); pln = patient.rs.getString(5); gender = patient.rs.getString(6); ag = patient.rs.getInt(7); wgt = patient.rs.getString(8); add = patient.rs.getString(9); cn = patient.rs.getString(10); dn = patient.rs.getString(11); sym = patient.rs.getString(12); dig = patient.rs.getString(13); fee = patient.rs.getInt(14); bg = patient.rs.getString(15); dir = patient.rs.getString(17); s = dir; repaint(); j13 = new JLabel("OLD IMAGE"); j13.setBounds(840, 5, 300, 300); JLabel j12 = new JLabel("OLD PHOTO") { public void paint(Graphics g) { ImageIcon ic = new ImageIcon(s); Image img = ic.getImage(); g.drawImage(img, 0, 0, 150, 150, this); } }; // q.flushAll() /*ImageIcon ic=new ImageIcon(dir); JLabel j12=new JLabel("",ic,JLabel.CENTER);*/ j12.setBounds(670, 70, 300, 300); // image.setBounds(700,300,100,100); q.add(j12); q.add(j13); repaint(); System.out.println("8743t32874" + dir); } catch (Exception e2) { } if (gender.equals("Male")) cm.setState(true); else cf.setState(true); tdt.setText(dt1); tpfnm.setText(pfn); tpmnm.setText(pmn); tplnm.setText(pln); tage.setText("" + ag); tfee.setText("" + fee); tadd.setText(add); tdig.setText(dig); tdnm.setText(dn); tsym.setText(sym); tcno.setText(cn); twt.setText(wgt); tbg.setText(bg); // cm.setState(set1State()); // cf.setSelectedCheckbox(gender); ba.setEnabled(false); bm.setEnabled(true); bd.setEnabled(true); } else { if (id == 0) { bl.setEnabled(true); ba.setEnabled(false); } else ba.setEnabled(true); bm.setEnabled(false); bd.setEnabled(false); } } }
public void read() { try { // patient.dt=""+tdt.getText(); patient.pid = Integer.parseInt(tpid.getText()); patient.pfnm = tpfnm.getText(); patient.pmnm = tpmnm.getText(); patient.plnm = tplnm.getText(); patient.gen = cbg.getSelectedCheckbox().getLabel(); try { patient.age = Integer.parseInt(tage.getText()); tage.setText("" + patient.age); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Invalid age inputed."); patient.age = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid age:")); tage.setText("" + patient.age); } try { int wet = Integer.parseInt(twt.getText()); twt.setText("" + wet); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Invalid weight inputed."); int wet = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid weight:")); twt.setText("" + wet); } patient.wt = twt.getText(); patient.addr = tadd.getText(); this.ad = tadd.getText(); System.out.println(tadd.getText()); while (true) { patient.cno = tcno.getText(); if (patient.cno.length() == 10) break; else { JOptionPane.showMessageDialog(null, "Invalid Phone No."); patient.cno = JOptionPane.showInputDialog("Please enter valid 10-digit Phone No.:"); tcno.setText(patient.cno); } } patient.dnm = tdnm.getText(); patient.sym = tsym.getText(); System.out.println(tsym.getText()); patient.dig = tdig.getText(); try { patient.fee = Integer.parseInt(tfee.getText()); tfee.setText("" + patient.fee); } catch (Exception e) { JOptionPane.showMessageDialog(null, "Invalid Fee inputed."); patient.fee = Integer.parseInt(JOptionPane.showInputDialog("Please enter valid Fee:")); tfee.setText("" + patient.fee); } patient.bg = tbg.getText(); patient.path = str; } catch (Exception e) { } }
public patientAdd(String s) { super(s); image = new JLabel() { public void paint(Graphics g) { ImageIcon ic = new ImageIcon(str); Image img = ic.getImage(); g.drawImage(img, 0, 0, 150, 150, this); } }; image.setBounds(670, 270, 300, 300); bu = new JButton("UPLOAD"); bu.setBounds(700, 230, 100, 20); bu.addActionListener(this); // q.add(bu); ldt = new JLabel("Date"); lpid = new JLabel("Patient ID"); lpnm = new JLabel("Patient Name"); lgen = new JLabel("Gender"); lbg = new JLabel("Blood Group"); lage = new JLabel("Age"); lwt = new JLabel("Weight Kg"); ladd = new JLabel("Address"); lcno = new JLabel("Cont. no."); ldnm = new JLabel("Doctor Name Dr."); lsym = new JLabel("Symptoms"); ldig = new JLabel("Diagnosis"); lfee = new JLabel("Fee Rs."); cbg = new CheckboxGroup(); cm = new Checkbox("Male", cbg, false); cm.addItemListener(this); cf = new Checkbox("Female", cbg, false); cf.setState(true); cf.addItemListener(this); tdt = new JTextField(15); tpid = new JTextField(6); tpid.addFocusListener(this); tpfnm = new JTextField("first"); tpmnm = new JTextField("middle"); tplnm = new JTextField("last"); tage = new JTextField(4); tage.addFocusListener(this); tbg = new JTextField(6); twt = new JTextField(5); tadd = new TextArea(patient.addr); tcno = new JTextField(20); tdnm = new JTextField(20); tsym = new TextArea(); tdig = new JTextField(20); tfee = new JTextField(6); tfee.addFocusListener(this); ba = new JButton("ADD"); ba.addActionListener(this); bm = new JButton("CANCEL"); bm.addActionListener(this); bd = new JButton("DELETE"); bd.addActionListener(this); bl = new JButton("DISPLAY"); bl.addActionListener(this); bs = new JButton("SEARCH"); bs.addActionListener(this); JPanel p = new JPanel(); p.add(ba); p.add(bm); // p.add(bd); // p.add(bl); // p.add(bs); add(p, BorderLayout.SOUTH); q = new JPanel(); q.setLayout(null); ldt.setBounds(1015, 20, 60, 20); q.add(ldt); tdt.setBounds(1060, 20, 170, 20); q.add(tdt); lpid.setBounds(70, 60, 80, 20); q.add(lpid); tpid.setBounds(200, 60, 60, 20); q.add(tpid); lpnm.setBounds(70, 100, 80, 20); q.add(lpnm); tpfnm.setBounds(200, 100, 100, 20); q.add(tpfnm); tpmnm.setBounds(320, 100, 100, 20); q.add(tpmnm); tplnm.setBounds(440, 100, 100, 20); q.add(tplnm); lgen.setBounds(70, 140, 60, 20); q.add(lgen); lbg.setBounds(370, 140, 80, 20); q.add(lbg); tbg.setBounds(470, 140, 60, 20); q.add(tbg); cm.setBounds(200, 140, 60, 20); cf.setBounds(280, 140, 60, 20); lage.setBounds(70, 180, 40, 20); q.add(lage); tage.setBounds(200, 180, 50, 20); q.add(tage); lwt.setBounds(370, 180, 200, 20); q.add(lwt); twt.setBounds(470, 180, 60, 20); q.add(twt); ladd.setBounds(70, 220, 60, 20); q.add(ladd); tadd.setBounds(200, 220, 350, 50); q.add(tadd); lcno.setBounds(70, 310, 60, 20); q.add(lcno); tcno.setBounds(200, 310, 120, 20); q.add(tcno); ldnm.setBounds(70, 350, 200, 20); q.add(ldnm); tdnm.setBounds(200, 350, 150, 20); q.add(tdnm); lsym.setBounds(70, 390, 100, 20); q.add(lsym); tsym.setBounds(200, 390, 300, 70); q.add(tsym); ldig.setBounds(70, 480, 60, 20); q.add(ldig); tdig.setBounds(200, 480, 100, 20); q.add(tdig); lfee.setBounds(70, 520, 200, 20); q.add(lfee); tfee.setBounds(200, 520, 40, 20); q.add(tfee); q.add(cm); q.add(cf); q.add(image); q.add(bu); add(q, BorderLayout.CENTER); addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { try { patient.con.close(); System.exit(0); } catch (Exception e8) { } } }); System.out.println(tadd.getText()); setSize(1330, 740); setVisible(true); }
/** Method declaration Clear SQL Statements. */ void clear() { ifHuge = ""; txtCommand.setText(ifHuge); }
DoctorInfomodify() { super("Doctor Information"); setSize(1200, 750); setLocationRelativeTo(null); setLayout(null); lmain = new JLabel("Doctor Information"); lmain.setBounds(440, 35, 107, 15); add(lmain); ldi = new JLabel("Doctor Information"); ldi.setBounds(40, 70, 120, 15); add(ldi); lname = new JLabel("Name :"); lname.setBounds(104, 97, 70, 25); add(lname); tfname = new JTextField(30); tfname.setBounds(270, 97, 250, 20); add(tfname); ladd = new JLabel("Address :"); ladd.setBounds(104, 138, 70, 15); add(ladd); taadd = new TextArea(); taadd.setBounds(270, 138, 250, 100); add(taadd); ltel = new JLabel("Contact :"); ltel.setBounds(575, 138, 50, 25); add(ltel); ldid = new JLabel("Doctor ID:"); ldid.setBounds(570, 97, 70, 25); add(ldid); tfdid = new JTextField(30); tfdid.setBounds(643, 97, 50, 20); add(tfdid); tftel = new JTextField(30); tftel.setBounds(640, 138, 200, 20); add(tftel); settings.Numvalidator(tftel); ldspec = new JLabel("Specialization :"); ldspec.setBounds(104, 310, 100, 25); add(ldspec); taspecial = new TextArea(); taspecial.setBounds(270, 310, 250, 100); add(taspecial); lwork = new JLabel("Working hours :"); lwork.setBounds(570, 310, 100, 15); add(lwork); lworkfrom = new JLabel("From :"); lworkfrom.setBounds(670, 305, 37, 25); add(lworkfrom); tfworkf = new JTextField(30); tfworkf.setBounds(710, 310, 30, 20); add(tfworkf); settings.Numvalidator(tfworkf); lworkto = new JLabel("to :"); lworkto.setBounds(747, 305, 20, 25); add(lworkto); tfworkt = new JTextField(30); tfworkt.setBounds(775, 310, 30, 20); add(tfworkt); settings.Numvalidator(tfworkt); bsub = new JButton("SEARCH", new ImageIcon("images/search.png")); bsub.setBounds(250, 643, 110, 30); add(bsub); bclr = new JButton("CLEAR", new ImageIcon("images/LOGGOFF.PNG")); bclr.setBounds(390, 643, 100, 30); add(bclr); bmod = new JButton("MODIFY", new ImageIcon("images/modify.png")); bmod.setBounds(530, 643, 100, 30); add(bmod); bback = new JButton("BACK", new ImageIcon("images/restore.png")); bback.setBounds(700, 643, 100, 30); add(bback); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); cn = DriverManager.getConnection("Jdbc:Odbc:doc"); } catch (Exception e) { System.out.println(e); } bclr.addActionListener(new clear()); bsub.addActionListener(new submit()); bmod.addActionListener(new modify()); bback.addActionListener(new back()); setVisible(true); }
public void actionPerformed(ActionEvent ae) { os = a.getText(); Pattern pat = Pattern.compile("[ .]"); String ms[] = pat.split(os), v; // Get whole String from Text area in tokens form Pattern pat1 = Pattern.compile("[ ]"); String ms1[] = pat1.split(os); // for string aaray int hcode[] = {100, 102, 220, 110, 111}, ecode[] = new int[20], j, p = 0; // p for check entry & hcode=Hindi lang.code ecode=English lang. code ResultSet rs; b.setText(""); try { Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe", "system", "student"); Statement stmt = con.createStatement(); for (i = 0; i <= ms.length; i++) { v = "'" + ms[i] + "'"; p = 0; if (p == 0) { rs = stmt.executeQuery("select hnoun from noun where enoun=" + v); while (rs.next()) { ms1[i] = (rs.getString(1)); p++; ecode[i] = 100; } } if (p == 0) { rs = stmt.executeQuery("select hhv from hv where ehv=" + v); while (rs.next()) { ms1[i] = (rs.getString(1)); p++; ecode[i] = 111; } } if (p == 0) { rs = stmt.executeQuery("select hneg from neg where eneg=" + v); while (rs.next()) { ms1[i] = (rs.getString(1)); p++; ecode[i] = 220; } } if (p == 0) { rs = stmt.executeQuery("select hverb from verb where everb=" + v); while (rs.next()) { ms1[i] = (rs.getString(1)); p++; ecode[i] = 110; } } if (p == 0) { rs = stmt.executeQuery("select hpre from pre where epre=" + v); while (rs.next()) { ms1[i] = (rs.getString(1)); p++; ecode[i] = 140; } } if (p == 0) { rs = stmt.executeQuery("select hpro from pro where epro=" + v); while (rs.next()) { ms1[i] = (rs.getString(1)); p++; ecode[i] = 102; } } if (p == 0) { rs = stmt.executeQuery("select hart from art where eart=" + v); while (rs.next()) { ms1[i] = (rs.getString(1)); p++; ecode[i] = 123; } } } con.close(); } catch (Exception e) { System.out.println(e); } for (i = 0; i < 5; i++) { for (j = 0; j < ms.length; j++) { if (hcode[i] == ecode[j]) { b.append(ms1[j] + " "); // print to hindi code wise } } } }