Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package metu.java.oracle;
- /**
- *
- * @author Okie Eko Wardoyo
- */
- import java.sql.*;
- public class MetuJavaOracle {
- public static void main(String[] args) {
- try{
- //tahap pertama register driver class
- Class.forName("oracle.jdbc.driver.OracleDriver");
- //tahab kedua creating connection
- Connection con=DriverManager.getConnection(
- "jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
- //tahab ketiga creating statement
- Statement stmt=con.createStatement();
- //tahab keempat Executing queries
- ResultSet rs=stmt.executeQuery("select * from table_metu");
- while(rs.next())
- System.out.println(rs.getString(1));
- //tahab kelima close connection
- con.close();
- }catch(Exception e){
- System.out.println(e);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement