티스토리 뷰


http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html 에서

Oracle Database 11g Release 2 / (11.2.0.1.0) /  Microsoft Windows (32-bit) / 파일 2 개 다운로드

다운로드한 2 개의 파일에서 \database\stage\Components 경로 내에 있는 파일 통합 (3개 파일)

설치 후 cmd -> sqlplus -> system/password 로 로그인. 혹은 
                      sqlplus "/as sysdba" 로 로그인(관리자) 



관리자 암호 잃어버린 경우

command에서 관리자모드로 로그인 후 alter user system identified by 암호;


scott 계정과 hr 계정 lock 해제

alter user scott identified by tiger account unlock

alter user hr identified by hr account unlock


접속

conn 사용자명/비밀번호


계정 생성

create user id identified by password;


접속 권한 부여

grant create session to user;


role을 이용한 권한 부여

create role 롤이름;

GRANT CREATE TABLE, ALTER ANY TABLE, DROP ANY TABLE TO 롤이름;

grant TableTask to User


테이블 스페이스 생성

create tablespace 테이블스페이스이름

datafile 파일경로

size 크기;


테이블 스페이스 사용 권한 부여

alter user 사용자

default tablespace 테이블스페이스 이름

quota unlimited on 테이블스페이스이름





오라클 접속 실습(JDBC 드라이버 필요)


- 주의 사항


설치된 경로에서 아래 폴더에 있는 ojdbc6 파일을 라이브러리에 등록해야함

D:\app\sec\product\11.2.0\dbhome_1\jdbc\lib


ojdbc6는 자바 JDK 버전에 따라 선택 (JDK 1.6 ver.)

현재 JDK 최신버전인 1.7도 ojdbc6 사용 


- 라이브러리 등록

자바프로젝트 우클릭 -> Build Path -> Configuration Build Path... 

-> Libraries -> Add external JARs... -> ojdbc6 선택



import java.sql.Connection;

import java.sql.DriverManager;

import java.sql.SQLException;


public class OracleTest {

static final String sid = "orcl";

static final String id = "kim";

static final String pass = "1234";


public static void main(String[] args) {

// TODO Auto-generated method stub

System.out.println("오라클 JDBC 드라이버 로딩중...");

try {

Class.forName("oracle.jdbc.driver.OracleDriver");

System.out.println("오라클 JDBC 드라이버 로딩 성공...");

} catch (ClassNotFoundException e) {

System.out.println("오라클 JDBC 드라이버 로딩 실패...");

System.out.println(e.getMessage());

System.exit(0);

}

Connection connection = null;

try {

String url = "jdbc:oracle:thin:@localhost:1521:" + sid;


connection = DriverManager.getConnection(url, id, pass);

System.out.println("접속/로그인 성공");

} catch (SQLException e) {

System.out.println("접속/로그인 실패");

}

try {

connection.close();

} catch (SQLException e) {

e.printStackTrace();

}

}

}



결과 :

오라클 JDBC 드라이버 로딩중...

오라클 JDBC 드라이버 로딩 성공...

접속/로그인 성공




'java,web study > 2주차 (7월 8일~14일)' 카테고리의 다른 글

Assertion  (0) 2013.07.14
UserException  (0) 2013.07.14
예외처리 03  (0) 2013.07.11
예외처리 02  (0) 2013.07.11
예외처리 01  (0) 2013.07.11
댓글
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/03   »
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
글 보관함