Advertisement
OKIEWARDOYO

JAVA SE NO 18 2

Oct 13th, 2013
5,981
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.97 KB | None | 0 0
  1. package metu.java.oracle;
  2.  
  3. /**
  4.  *
  5.  * @author Okie Eko Wardoyo
  6.  */
  7. import java.sql.*;
  8. public class MetuJavaOracle {
  9.  
  10.     public static void main(String[] args) {
  11.         try{
  12.             //tahap pertama register driver class
  13.             Class.forName("oracle.jdbc.driver.OracleDriver");
  14.            
  15.             //tahab kedua creating connection
  16.             Connection con=DriverManager.getConnection(  
  17. "jdbc:oracle:thin:@localhost:1521:xe","system","oracle");
  18.            
  19.             //tahab ketiga creating statement
  20.             Statement stmt=con.createStatement();
  21.            
  22.             //tahab keempat Executing queries
  23.             ResultSet rs=stmt.executeQuery("select * from table_metu");
  24.            
  25.             while(rs.next())
  26.                 System.out.println(rs.getString(1));
  27.            
  28.             //tahab kelima close connection
  29.             con.close();
  30.         }catch(Exception e){
  31.             System.out.println(e);
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement