-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava_Jdbc.java
More file actions
27 lines (21 loc) · 848 Bytes
/
Java_Jdbc.java
File metadata and controls
27 lines (21 loc) · 848 Bytes
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
import java.sql.*;
public class Java_Jdbc {
public static void main(String[] args) throws SQLException, ClassNotFoundException {
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","system");
Statement statement=con.createStatement();
ResultSet rs=statement.executeQuery("select * from employees");
while(rs.next()){
System.out.print("FName"+rs.getString(1));
System.out.print("\tLName :"+rs.getString(4));
System.out.println("\tSalary :"+rs.getInt(8));
}
con.close();
statement.close();
rs.close();
}catch(SQLException e){
e.printStackTrace();
}
}
}