File tree Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Expand file tree Collapse file tree 1 file changed +49
-0
lines changed Original file line number Diff line number Diff line change 1+ package testdatabase ;
2+
3+ import java .sql .Connection ;
4+ import java .sql .DriverManager ;
5+ import java .sql .ResultSet ;
6+ import java .sql .SQLException ;
7+ import java .sql .Statement ;
8+
9+ class TestDatabase28
10+ {
11+ public static void main (String args [])
12+ {
13+ Connection con = null ;
14+ Statement st = null ;
15+ ResultSet rs = null ;
16+
17+ try
18+ {
19+ Class .forName ("sun.jdbc.odbc.JdbcOdbcDriver" );
20+ System .out .println ("Driver Loaded" );
21+
22+ con = DriverManager .getConnection ("jdbc:odbc:db28" );
23+ System .out .println ("Connected" );
24+
25+ st = con .createStatement ();
26+
27+ String query = "Select * from emp" ;
28+
29+ rs = st .executeQuery (query );
30+
31+ while (rs .next ())
32+ {
33+ System .out .print (rs .getString (1 ) + "\t " );
34+ System .out .print (rs .getString (2 ) + "\t " );
35+ System .out .print (rs .getString (3 ) + "\t " );
36+ System .out .println (rs .getString (4 ));
37+ }
38+ con .close ();
39+ }
40+ catch (ClassNotFoundException e )
41+ {
42+ System .out .println (e );
43+ }
44+ catch (SQLException e )
45+ {
46+ System .out .println (e );
47+ }
48+ }
49+ }
You can’t perform that action at this time.
0 commit comments