반응형


import java.sql.*;

public class jdbctest {
  String driver_name;
  String URL;
  String uid;
     String passwd;

     Connection con;
     Statement stmt;
     ResultSet rs;
 
     public jdbctest() {
      //주의 : @//PC_이름:1521/orcl쓸것
   URL="jdbc:oracle:thin:@localhost:1521/orcl";
   uid="scott";
   passwd="tiger";
     }  
  public static void main(String[] args){
   jdbctest x = new jdbctest();
   x.DB_Connection();
   x.DB_DisConnection();
  }
  public void DB_Connection() {
         try{
    DriverManager.registerDriver(
      new oracle.jdbc.driver.OracleDriver());
    con = DriverManager.getConnection(URL,uid,passwd);
    stmt = con.createStatement();
    rs=stmt.executeQuery("SELECT * FROM STUDENT");
         }catch(SQLException e)
         {
             e.printStackTrace();
         }
  }
  public void DB_DisConnection(){
   try{
    con.close();
   }catch(SQLException e){
    e.printStackTrace();
   }
  }
}

반응형

'DB > Oracle' 카테고리의 다른 글

Oracle 10g  (0) 2007.03.13
Posted by Real_G