-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDbclass.java
36 lines (31 loc) · 1.14 KB
/
Dbclass.java
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
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.JOptionPane;
public class Dbclass {
public static final String URL = "jdbc:oracle:thin:@localhost:1521:xe";
public static final String USER = "system";
public static final String PASS = "tannu";
Connection con;
Statement st;
ResultSet rs ;
public Dbclass(){
try {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (ClassNotFoundException ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
}
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","tannu");
st = con.createStatement();
rs = st.executeQuery("select * from customers");
while(rs.next()){
System.out.println(rs.getString("city"));
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, ex.getMessage());
}
}
}