-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJDBC.java
More file actions
957 lines (657 loc) · 26.4 KB
/
JDBC.java
File metadata and controls
957 lines (657 loc) · 26.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
/* =======================================================================
A generic GUI for the JDBC project
Author: Shun Yan Cheung
To compile the project:
javac JDBC.java
To run the project:
java -cp ".:/home/cs377001/lib/mysql-connector-java.jar" JDBC
Honor Code: This work is completed only by Melanie without consulting others except the instructor and TA
======================================================================= */
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
public class JDBC
{
public static JFrame mainFrame;
/* ***************************************************************
The class variables (defined using static) defined in this area
can be accessed by other "call back" classes
You can define your SHARED program variables below this line
SHARED variables are variables that you need to use in
MULTIPLE methods
(If you ONLY use a variable inside ONE method, define that
variable as a LOCAL variable inside THAT method)
*************************************************************** */
public static boolean DatabaseSelected;
public static Statement stmt=null ;
public static Connection conn=null;
public static ResultSet rset;
public static ResultSetMetaData meta;
public static int NCols=0;
public static String s="";
/* *********************************************************
TODO 1: Define you SHARED program variables here
SHARED variables are variables that will can
be used by methods in *different* classes
********************************************************* */
/* ********************************************************************
End area where you define your SHARED program variables
******************************************************************* */
/* vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
This area contain SHARED object variables for the GUI application
Do NOT make any changes to the variable sections below
You can use these GUI variables to code your GUI application:
Input: a JTextArea object
Input.getText() will return the SQL query that you
need to execute
Output: a JTextArea object
(1) Use Output.setText("") to clear the text area
(2) Then use Output.append( ... ) to print text
Use Output.append("\n") to advance to next line
DBName: a JTextField object.
DBName.getText() will return the database name
Select: a JButton object.
Activate this object to process "Select database" function
Execute: a JButton object.
Activate this object to process "Execute query" function
Column: a JTextField object.
Column.getText() will return the column number
Max: a JButton object.
Activate this object to process "Max" function
Min: a JButton object.
Activate this object to process "Min" function
Avg: a JButton object.
Activate this object to process "Avg" function
Median: a JButton object.
Activate this object to process "Median" function
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */
/* ==========================================================
The query input area
========================================================== */
public static JTextArea Input = new JTextArea(); // Query input !!!
// Get the query text here
/* ==========================================================
The query output area
========================================================== */
public static JTextArea Output = new JTextArea(); // Query output !!
// Print tuples here
/* ==========================================================
The TOP-RIGHT panel things
========================================================== */
// Database label and name
public static JLabel DBLabel = new JLabel("Database: ");
public static JTextField DBName = new JTextField(); // Database name !!
// The database selection button
public static JButton Select = new JButton("Select"); // Select button !!
// The query execution button
public static JButton Execute = new JButton("Execute"); // Execute button !!
/* ==========================================================
The BOTTON-RIGHT panel things
========================================================== */
// The column selection field
public static JLabel ColumnLabel = new JLabel("Column: ");
public static JTextField Column = new JTextField(); // Column number !!
// The MAX output field and button
public static JTextField MaxText = new JTextField();
public static JButton Max = new JButton("Maximum"); // Max button !!
// The MIN output field and button
public static JTextField MinText = new JTextField();
public static JButton Min = new JButton("Minimum"); // Min button !!
// The Average output field and button
public static JTextField AvgText = new JTextField();
public static JButton Avg = new JButton("Average"); // Avg button !!
// The Median output field and button
public static JTextField MedianText = new JTextField();
public static JButton Median = new JButton("Median"); // Median button !!
/* ********************************************************************
The main program
******************************************************************** */
public static void main( String[] args )
{
try
{
// Load the MySQL JDBC driver
Class.forName("com.mysql.jdbc.Driver");
// System.out.println(1);
}
catch (Exception e)
{
Output.setText("Cannot load the JDBC drive");
}
/* ===============================================
Make the window
=============================================== */
MakeGUIWindow();
/* =====================================================
Make the Select button active:
===================================================== */
Select.addActionListener(new SelectListener() );
// Make Select button execute the actionPerform() method
// inside the class SelectListener (see below)
/* **********************************************************
TODO 2: make the OTHER buttons active
(Execute, Max, Min, Avg, Median)
Make the buttons perform the functions given in HW
********************************************************** */
// I did this in class....
Execute.addActionListener(new myExecuteClass() );
Max.addActionListener(new MaxListener());
Min.addActionListener(new MinListener());
Avg.addActionListener(new AvgListener());
Median.addActionListener(new MedianListener());
/* ***************************************
test should be delete
double myNumber = Double.parseDouble("1234.2345");
String decimal = "0.";
for (int i = 0;i<2;i++){
decimal+="0";
}
DecimalFormat form = new DecimalFormat(decimal);
//String number;
String s;
s =form.format(myNumber).toString();
System.out.println(s);
***************************************** */
}
// I did this in class....
static class myExecuteClass implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
Output.setText("");
if ( DatabaseSelected == false) {
Output.setText("No database was selected");
return;
}
//int[] length = new int[100];
s = Input.getText( );
try
{
rset = stmt.executeQuery( s ); // Exec query
meta = rset.getMetaData(); // Get meta data
NCols = meta.getColumnCount();
System.out.println("rset completed");
int line=0;
/* ===================================================
**** Print the column names before any data ****
=================================================== */
for ( int i = 1; i <= NCols; i++ )
{
String name;
name = meta.getColumnName(i);
int columnwidth =0;//initailly, set every column's width to 0, and store column width into this variable later
if (meta.getColumnType(i) == java.sql.Types.DECIMAL ||
meta.getColumnType(i) == java.sql.Types.INTEGER)
{
columnwidth = 10;
line += columnwidth;
}
else{//if it is string type
columnwidth=Math.max(6,meta.getColumnDisplaySize(i));
line += columnwidth;
}
if (name.length()>10){name=name.substring(0,10);}
Output.append( name ); // Print field name
/* ----------------------------------------------
****Pad**** the attr name i to columnwidth
---------------------------------------------- */
for (int j = name.length(); j < columnwidth+1; j++)
Output.append(" ");
}
Output.append("\n");
/* ---------------------------------
Print a dividing line....
--------------------------------- */
for ( int j = 1; j <= line+NCols-1; j++)
Output.append("="); // Print a dividing line
Output.append("\n");
/* ===========================================
Fetch and print one row at a time....
=========================================== */
while ( rset.next () ) // Advance to next row
{
/* ===========================================
Fetch the columns (attributes) from a row
=========================================== */
for(int i = 1; i <= NCols; i++)
{
int columnwidth =0;
if (meta.getColumnType(i) == java.sql.Types.DECIMAL ||
meta.getColumnType(i) == java.sql.Types.INTEGER)
{//type is decimal or integer
columnwidth = 10;
String nextItem;
int scale;
nextItem = rset.getString(i);
scale = meta.getScale(i);
if (nextItem == null){
for (int j = 1;j<=(columnwidth-4);j++){Output.append(" ");}//right align,pad space first
Output.append("NULL");
Output.append(" ");
}
else{//if it is not equal to null
if (scale!=0){//means it is decimal
double myNumber = Double.parseDouble(nextItem);
String decimal = "0.";
for (int m= 0;m<scale;m++){
decimal+="0";
}
DecimalFormat form = new DecimalFormat(decimal);
//String number;
nextItem =form.format(myNumber).toString();
}
for (int j = nextItem.length(); j < columnwidth; j++)
Output.append(" ");
Output.append(nextItem);
Output.append(" ");
}
}
else{//type is string, left align
columnwidth=Math.max(6,meta.getColumnDisplaySize(i));
String nextItem;
nextItem = rset.getString(i);
if (nextItem == null){
Output.append("NULL");
for (int j = 1;j<=(columnwidth-4);j++){Output.append(" ");}//right align,pad space first
Output.append(" ");
}
else{
//if it is not equal to null
Output.append(nextItem);
for (int j = nextItem.length(); j < columnwidth; j++)
Output.append(" ");
Output.append(" ");
}
}
}
Output.append("\n");
}
//rset.close(); // Free result set buffers
}
catch (Exception error)
{
String errMsg=error.getMessage();
Output.setText(errMsg); // Print the error message
}
}
}
/* ===============================================================
***** Sample "call back" class
Listener class for the Select button
=============================================================== */
static class SelectListener implements ActionListener
{
/* =============================================================
The "actionPerformed( )" method will be called
when a button is pressed
You must ASSOCIATE a button to this class using this call:
ButtonObject.addActionListener( new SelectListener( ) )
============================================================= */
public void actionPerformed(ActionEvent e)
{
/* ===========================================================
You must replace these statements with statements that
perform the "SELECT button" function:
1. make a connection to the database server
2. allocate statement object to prepare for
query execution
=========================================================== */
// =============================================================
// Dummy statements to show that the activation was successful
// =============================================================
String url = "jdbc:mysql://holland.mathcs.emory.edu:3306/";
String dbName = DBName.getText();
String userName = "cs377";
String password = "abc123";
DatabaseSelected =false;
if(stmt!=null){
try {
stmt.close();
System.out.println("Free Statement object resources");
}catch(Exception error){
Output.setText("Cannot Free Statement object resources");
}
}
if (conn!=null){
try{
conn.close();
System.out.println("Close SQL server connection");
}catch(Exception error){
Output.setText("cannot close SQL server connection");
}
}
try
{
// Connect to the database
conn = DriverManager.getConnection(url+dbName,userName,password);
// Create statement object to send query to SQL server
stmt = conn.createStatement ();
DatabaseSelected = true;
System.out.println(DatabaseSelected);
System.out.println("Connection established to " + dbName);
}
catch (Exception error)
{
Output.setText("Cannot open databass"+DBName.getText());
}
System.out.println("The method actionPerformed");
System.out.println("in the class SelectListener was called\n");
}
}
/* ===============================================================
TODO 3:
***** Write OTHER "call back" classes here for other buttons
(Execute, Max, Min, Avg, Median)
=============================================================== */
static class MinListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
String columnNum = Column.getText();
int ColumnNum = Integer.parseInt(columnNum);//this give us the integer of the column we want to calculate
if (ColumnNum>NCols) {
MinText.setText("col # err");
return;
}
//after handling the error, find certian column and retreive number
Double doublemin = Double.POSITIVE_INFINITY;
String stringmin = "";
try {
s=Input.getText();
rset=stmt.executeQuery(s);
meta=rset.getMetaData();
if (meta.getColumnType(ColumnNum) == java.sql.Types.DECIMAL ||
meta.getColumnType(ColumnNum) == java.sql.Types.INTEGER )
{
// process column data as float
if(rset.getString(ColumnNum)!=null){
doublemin = rset.getDouble(ColumnNum);
}
//
}
else
{ while(rset.next()){
if (rset.getString(ColumnNum)!=null){
stringmin = rset.getString(ColumnNum);
rset.beforeFirst();
break;}
}
// process column data as string
//MinText.setText(stringmin);
}
} catch (Exception e1) {
}
try {
if (meta.getColumnType(ColumnNum) == java.sql.Types.DECIMAL ||
meta.getColumnType(ColumnNum) == java.sql.Types.INTEGER )
{
while(rset.next()){
if(rset.getString(ColumnNum)==null) continue;
if (rset.getDouble(ColumnNum)<doublemin) doublemin=rset.getDouble(ColumnNum);
}
MinText.setText(String.valueOf(doublemin));
}
else{
while(rset.next()){
if(rset.getString(ColumnNum)==null) continue;
if (rset.getString(ColumnNum).compareTo(stringmin)<0) stringmin=rset.getString(ColumnNum);
}
MinText.setText(stringmin);
}
}catch (Exception e1) {
}
}
}
static class MaxListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
String columnNum = Column.getText();
int ColumnNum = Integer.parseInt(columnNum);//this give us the integer of the column we want to calculate
if (ColumnNum>NCols) {
MaxText.setText("col # err");
return;
}
//after handling the error, find certian column and retreive number
Double doublemax = 0.00;
String stringmax = "";
try {
s=Input.getText();
rset=stmt.executeQuery(s);
meta=rset.getMetaData();
if (meta.getColumnType(ColumnNum) == java.sql.Types.DECIMAL ||
meta.getColumnType(ColumnNum) == java.sql.Types.INTEGER )
{
// process column data as float
if(rset.getString(ColumnNum)!=null){
doublemax = rset.getDouble(ColumnNum);
}
//
}
else
{ while(rset.next()){
if (rset.getString(ColumnNum)!=null){
stringmax = rset.getString(ColumnNum);
rset.beforeFirst();
break;}
}
// process column data as string
//MinText.setText(stringmin);
}
} catch (Exception e1) {
}
try {
if (meta.getColumnType(ColumnNum) == java.sql.Types.DECIMAL ||
meta.getColumnType(ColumnNum) == java.sql.Types.INTEGER )
{
while(rset.next()){
if(rset.getString(ColumnNum)==null) continue;
if (rset.getDouble(ColumnNum)>doublemax) doublemax=rset.getDouble(ColumnNum);
}
MaxText.setText(String.valueOf(doublemax));
}
else{
while(rset.next()){
if(rset.getString(ColumnNum)==null) continue;
if (rset.getString(ColumnNum).compareTo(stringmax)>0) stringmax=rset.getString(ColumnNum);
}
MaxText.setText(stringmax);
}
}catch (Exception e1) {
}
}
}
static class AvgListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
String columnNum = Column.getText();
int ColumnNum = Integer.parseInt(columnNum);//this give us the integer of the column we want to calculate
if (ColumnNum>NCols) {
AvgText.setText("col # err");
return;
}
//after handling the error, find certian column and retreive number
double doublesum=0;
int withoutnullcount=0;
try {
s=Input.getText();
rset=stmt.executeQuery(s);
meta=rset.getMetaData();
if (meta.getColumnType(ColumnNum) == java.sql.Types.DECIMAL ||
meta.getColumnType(ColumnNum) == java.sql.Types.INTEGER )
{
// process column data as float
if(rset.getString(ColumnNum)!=null){
doublesum = rset.getDouble(ColumnNum);
withoutnullcount++;
}
//
}
else
{ // process column data as string
AvgText.setText("Not num");
return;
}
} catch (Exception e1) {
}
try {
while(rset.next()){
if(rset.getString(ColumnNum)==null) continue;
doublesum += rset.getDouble(ColumnNum);
withoutnullcount++;
}
float average = (float)doublesum/withoutnullcount;
AvgText.setText(String.valueOf(average));
}catch (Exception e1) {
}
}
}
static class MedianListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
String columnNum = Column.getText();
int ColumnNum = Integer.parseInt(columnNum);//this give us the integer of the column we want to calculate
if (ColumnNum>NCols) {
MedianText.setText("col # err");
return;
}
int withoutnullcount=0;
ArrayList<Double> doublelist = new ArrayList<Double>();
ArrayList<String> stringlist = new ArrayList<String>();
try {
s=Input.getText();
rset=stmt.executeQuery(s);
meta=rset.getMetaData();
if (meta.getColumnType(ColumnNum) == java.sql.Types.DECIMAL ||
meta.getColumnType(ColumnNum) == java.sql.Types.INTEGER )
{
// process column data as float
if(rset.getString(ColumnNum)!=null){
doublelist.add(rset.getDouble(ColumnNum));
withoutnullcount++;
}
//
}
else
{ // process column data as string
if(rset.getString(ColumnNum)!=null){
stringlist.add(rset.getString(ColumnNum));
withoutnullcount++;
}
}
} catch (Exception e1) {
}
try {
if (meta.getColumnType(ColumnNum) == java.sql.Types.DECIMAL ||
meta.getColumnType(ColumnNum) == java.sql.Types.INTEGER )
{
while(rset.next()){
if(rset.getString(ColumnNum)==null) continue;
doublelist.add(rset.getDouble(ColumnNum));
withoutnullcount++;
}
int num = (withoutnullcount+1)/2;
Collections.sort(doublelist);
double doublemedian = doublelist.get(num-1);
MedianText.setText(String.valueOf(doublemedian));
}
else{
while(rset.next()){
if(rset.getString(ColumnNum)==null) continue;
stringlist.add(rset.getString(ColumnNum));
withoutnullcount++;
}
int num = (withoutnullcount+1)/2;
Collections.sort(stringlist);
String stringmedian=stringlist.get(num-1);
MedianText.setText(stringmedian);
}
}catch (Exception e1) {
}
}
}
/* **********************************************************
This section of the program makes the GUI
DO NOT make any changes to the code below !!!
********************************************************** */
/* ===============================================================
Make GUI window
=============================================================== */
public static void MakeGUIWindow()
{
Font ss_font = new Font("SansSarif",Font.BOLD,16) ;
Font ms_font = new Font("Monospaced",Font.BOLD,16) ;
JPanel P1 = new JPanel(); // Top panel
JPanel P2 = new JPanel();
P1.setLayout( new BorderLayout() );
P2.setLayout( new BorderLayout() );
/* =============================================
Make top panel
============================================= */
JScrollPane d1 = new JScrollPane(Input,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
Input.setFont( ss_font );
JPanel s1 = new JPanel(); // Side panel
s1.setLayout( new GridLayout( 8,1 ) );
s1.add( DBLabel );
s1.add( DBName );
DBName.setEditable(true);
DBName.setFont( ss_font );
s1.add( Select );
s1.add( Execute );
Execute.setPreferredSize(new Dimension(140, 30)) ;
P1.add(d1, "Center");
P1.add(s1, "East");
/* =============================================
Make bottom panel
============================================= */
JScrollPane d2 = new JScrollPane(Output,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ,
JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
Output.setFont( ms_font );
Output.setEditable(false);
JPanel s3 = new JPanel(); // Put ColumnLabel and Column on 1 row
s3.add(ColumnLabel);
s3.add(Column);
Column.setFont( ss_font );
Column.setPreferredSize(new Dimension(40, 30)) ;
JPanel s2 = new JPanel(); // Side panel
s2.setLayout( new GridLayout( 10,1 ) );
s2.add( s3 );
MaxText.setPreferredSize(new Dimension(140, 30)) ;
s2.add( MaxText );
MaxText.setFont( ss_font );
MaxText.setEditable(false);
s2.add( Max );
s2.add( MinText );
MinText.setFont( ss_font );
MinText.setEditable(false);
s2.add( Min );
s2.add( AvgText );
AvgText.setFont( ss_font );
AvgText.setEditable(false);
s2.add( Avg );
s2.add( MedianText );
MedianText.setFont( ss_font );
MedianText.setEditable(false);
s2.add( Median );
P2.add(d2, "Center");
P2.add(s2, "East");
mainFrame = new JFrame("CS377 JDBC project");
mainFrame.getContentPane().setLayout( new GridLayout(2,1) );
mainFrame.getContentPane().add( P1 );
mainFrame.getContentPane().add( P2 );
mainFrame.setSize(900, 700);
/* =================================================
Exit application if user press close on window
This will clean up the network connection....
================================================= */
// mainFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
mainFrame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.out.println("\nGood-bye.Thanks for using CS377-sql...\n");
System.exit(0);
}
});
mainFrame.setVisible(true);
}
}