728x90

대용량 처리 자료형 : LOB
대용량 문자처리 자료형 : CLOB

  • char의 C + LOB

 

clob의 필요성

varchar2는 최대 4000byte이기 때문에 4000byte가 넘는 고용량들을 다룰 때, clob이 필요

 


문제점

CLOB을 그냥 쓰면 자바 객체 출력 때처럼 객체주소가 찍혀 나오는 것처럼 출력됨

 

해결책

DBMS_LOB.SUBSTR() 사용

 

DBMS_LOB.SUBSTR()

DBMS_LOB.SUBSTR(CLOB컬럼명, 자를 문자 수, 시작위치offset) 

 

주의사항

1)TO_CLOB()으로 감싸기

TO_CLOB(클롭컬럼명)으로 감싸지 않으면, 식별자가 너무 길다는 오류 발생 가능성

TO_CLOB(CONTENT)

2)길이 한도

CLOB 자체는 4000넘어도 되지만 DBMS_LOB.SUBSTR()을 쓰면 4000까지만 가능
따라서, 4000이 넘는 CLOB데이터를 조회할 때는 이어 붙여야함
||이나 concat() 사용
ex) 1-4000 + 4001-8000 식으로 문자열 이어 붙이는 방법

DBMS_LOB.SUBSTR(col1, 4000, 1) || DBMS_LOB.SUBSTR(col1, 4000, 4001) AS CONTENTS 
SELECT 
    TITLE, 
    WRTIER,
    DBMS_LOB.SUBSTR(col1, 4000, 1) || DBMS_LOB.SUBSTR(col1, 4000, 4001) AS CONTENTS
FROM BOARD

 

 

관련 함수

DBMS_LOB.INSTR(CLOB컬럼명, '검색할 단어', 몇번째 위치한 단어)  // 찾으려는 문자열의 인덱스번호 반환
DBMS_LOB.GETLENGTH(CLOB컬럼명)                         // 해당 컬럼의 길이 반환

1)DBMS_LOB.INSTR()

지정한 문자열이 나올 때마다 해당 인덱스 번호 반환
LIKE보다 조회 빠름

2)DBMS_LOB.GETLENGTH()

해당 컬럼의 전체 길이 반환(공백 포함)

 

 

참고자료
https://developyo.tistory.com/364
https://joongwoonc.tistory.com/52

728x90
반응형
728x90

 

1. 브랜치(branch) 생성 : branch

$ git branch 브랜치명

예시

$ git branch test1

2.브랜치(branch) 변경 : checkout

$ git checkout 브랜치명

 

 ※ 브랜치(branch) 생성 및 변경 한번에

-b 추가

$ git checkout **-b** 브랜치명

3.Merge

$ git **merge** <commit>

 

4. 브랜치(branch) 삭제 : branch -d

$ git **branch -d** 브랜치명

 

 

 

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository
$ git init
Initialized empty Git repository in D:/Git_Repository/.git/

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch -b test1
error: unknown switch `b'
usage: git branch [<options>] [-r | -a] [--merged] [--no-merged]
   or: git branch [<options>] [-f] [--recurse-submodules] <branch-name> [<start-point>]
   or: git branch [<options>] [-l] [<pattern>...]
   or: git branch [<options>] [-r] (-d | -D) <branch-name>...
   or: git branch [<options>] (-m | -M) [<old-branch>] <new-branch>
   or: git branch [<options>] (-c | -C) [<old-branch>] <new-branch>
   or: git branch [<options>] [-r | -a] [--points-at]
   or: git branch [<options>] [-r | -a] [--format]

Generic options
    -v, --verbose         show hash and subject, give twice for upstream branch
    -q, --quiet           suppress informational messages
    -t, --track[=(direct|inherit)]
                          set branch tracking configuration
    -u, --set-upstream-to <upstream>
                          change the upstream info
    --unset-upstream      unset the upstream info
    --color[=<when>]      use colored output
    -r, --remotes         act on remote-tracking branches
    --contains <commit>   print only branches that contain the commit
    --no-contains <commit>
                          print only branches that don't contain the commit
    --abbrev[=<n>]        use <n> digits to display object names

Specific git-branch actions:
    -a, --all             list both remote-tracking and local branches
    -d, --delete          delete fully merged branch
    -D                    delete branch (even if not merged)
    -m, --move            move/rename a branch and its reflog
    -M                    move/rename a branch, even if target exists
    -c, --copy            copy a branch and its reflog
    -C                    copy a branch, even if target exists
    -l, --list            list branch names
    --show-current        show current branch name
    --create-reflog       create the branch's reflog
    --edit-description    edit the description for the branch
    -f, --force           force creation, move/rename, deletion
    --merged <commit>     print only branches that are merged
    --no-merged <commit>  print only branches that are not merged
    --column[=<style>]    list branches in columns
    --sort <key>          field name to sort on
    --points-at <object>  print only branches of the object
    -i, --ignore-case     sorting and filtering are case insensitive
    --recurse-submodules  recurse through submodules
    --format <format>     format to use for the output


csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test1
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git help
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--super-prefix=<path>] [--config-env=<name>=<envvar>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone     Clone a repository into a new directory
   init      Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add       Add file contents to the index
   mv        Move or rename a file, a directory, or a symlink
   restore   Restore working tree files
   rm        Remove files from the working tree and from the index

examine the history and state (see also: git help revisions)
   bisect    Use binary search to find the commit that introduced a bug
   diff      Show changes between commits, commit and working tree, etc
   grep      Print lines matching a pattern
   log       Show commit logs
   show      Show various types of objects
   status    Show the working tree status

grow, mark and tweak your common history
   branch    List, create, or delete branches
   commit    Record changes to the repository
   merge     Join two or more development histories together
   rebase    Reapply commits on top of another base tip
   reset     Reset current HEAD to the specified state
   switch    Switch branches
   tag       Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch     Download objects and refs from another repository
   pull      Fetch from and integrate with another repository or a local branch
   push      Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test1
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch master
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git checkout test1
error: pathspec 'test1' did not match any file(s) known to git

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git checkout test
error: pathspec 'test' did not match any file(s) known to git

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch a
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ ls -al
total 20
drwxr-xr-x 1 csy62 197609 0 Jul 31 03:18 ./
drwxr-xr-x 1 csy62 197609 0 Jul 14 08:20 ../
drwxr-xr-x 1 csy62 197609 0 Jul 31 03:17 .git/
-rw-r--r-- 1 csy62 197609 0 Jul 31 03:18 a.txt

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch 'test'
fatal: not a valid object name: 'master'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git commit -m 1
On branch master

Initial commit

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        a.txt

nothing added to commit but untracked files present (use "git add" to track)

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git add a.txt

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git commit -m 1
[master (root-commit) 0505a6a] 1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 a.txt

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch test

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (master)
$ git branch -m test1

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
  test
* test1

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test
Switched to branch 'test'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test)
$ git checkout -b test2
Switched to a new branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch
  test
  test1
* test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test
Switched to branch 'test'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test)
$ git branch -m test0

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test0)
$ git branch
* test0
  test1
  test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test0)
$ git branch -d test2
Deleted branch test2 (was 0505a6a).

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test0)
$ git checkout -b test2
Switched to a new branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Already up to date.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 1
On branch test2
nothing to commit, working tree clean

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch
  test0
  test1
* test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch -d test2
error: Cannot delete branch 'test2' checked out at 'D:/Git_Repository'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout -b test3
Switched to a new branch 'test3'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test3)
$ git checkout test2
Switched to branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch -d test3
Deleted branch test3 (was 0505a6a).

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test2
Already on 'test2'
A       "a - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'
A       "a - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Already up to date.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'
A       "a - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 1
[test2 76d033f] 1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test1
Already up to date.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge test3
merge: test3 - not something we can merge

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge test1
Already up to date.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git branch
  test0
  test1
* test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge master
merge: master - not something we can merge

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git show
commit 76d033f78943e8d9856b60b2c323dd80098a23fe (HEAD -> test2)
Author: neverGiveUpppppp <csy6219@naver.com>
Date:   Sun Jul 31 03:30:07 2022 +0900

    1

diff --git "a/a - \353\263\265\354\202\254\353\263\270.txt" "b/a - \353\263\265\354\202\254\353\263\270.txt"
new file mode 100644
index 0000000..e69de29

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git status
On branch test2
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        new file:   "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"


csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 1
[test2 c0f83ba] 1
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git merge
fatal: No remote for the current branch.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git test1
git: 'test1' is not a git command. See 'git --help'.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Updating 0505a6a..c0f83ba
Fast-forward
 ...65\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt" | 0
 "a - \353\263\265\354\202\254\353\263\270.txt"                            | 0
 2 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git status
On branch test1
nothing to commit, working tree clean

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git show
commit c0f83baab10cff7a90120db6ba4f3975c3e743f7 (HEAD -> test1, test2)
Author: neverGiveUpppppp <csy6219@naver.com>
Date:   Sun Jul 31 03:32:43 2022 +0900

    1

diff --git "a/a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt" "b/a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"
new file mode 100644
index 0000000..e69de29

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
  test0
* test1
  test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git commit -m 2
[test2 d4529f8] 2
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git add .

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git commit -m 3
On branch test1
nothing to commit, working tree clean

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
  test0
* test1
  test2

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test3
error: pathspec 'test3' did not match any file(s) known to git

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git checkout test2
Switched to branch 'test2'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test2)
$ git checkout test1
Switched to branch 'test1'

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch -d test2
error: The branch 'test2' is not fully merged.
If you are sure you want to delete it, run 'git branch -D test2'.

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git merge test2
Updating c0f83ba..d4529f8
Fast-forward
 ...65\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt" | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 "a - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270 - \353\263\265\354\202\254\353\263\270.txt"

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch -d test2
Deleted branch test2 (was d4529f8).

csy62@DESKTOP-QNAHH4K MINGW64 /d/Git_Repository (test1)
$ git branch
  test0
* test1
728x90
반응형
728x90

 

배열 선언 
배열 할당
배열 초기화 : 인덱스,중괄호,for문
배열 삭제 : null
배열 값 출력하는 방법 2가지 : for문, Arrays.toString()
배열 복사 : shallow copy & deep copy

 

코드 익히기 & 배운 것들


배열 크기 변경 불가(삭제하고 새로 만들기에 주소값이 변경됨)
배열 안 값이 최대길이보다 짧으면 값만큼만 출력되서 나옴(여분공간에 다른값x)
dArr[3] = 3; // 3.0으로 출력 -> 자동형변환(int to double) 
초기화 for문 방법은 int만 가능하나, 실수로 형변환 가능한 int면 for문 가능 -> int인 i가 실수로 변환 가능한 수이기에 

 

public void arrayPractice() {
    // 배열 선언 
    // 배열 할당
    // 배열 초기화 : 인덱스,중괄호,for문
    // 배열 삭제 : null
    // 배열 값 출력하는 방법 2가지 : for문, Arrays.toString()
    // 배열 복사 : shallow copy & deep copy
    //
    // 		배열 크기 변경 불가(삭제하고 새로 만들기에 주소값이 변경됨)
    //		배열 안 값이 최대길이보다 짧으면 값만큼만 출력되서 나옴(여분공간에 다른값x)
    //		dArr[3] = 3;	// 3.0으로 출력 -> 자동형변환(int to double) 
    // 		초기화 for문 방법은 int만 가능하나, 실수로 형변환 가능한 int면 for문 가능 -> int인 i가 실수로 변환 가능한 수이기에 
    // 		null인 배열값 확인 시, for문방법은 널포인트익셉션 쓰므로 Arrays.toString() 사용해야함

    //배열 선언
    String[] arr; // Stack 영역에 공간 생성

    //배열 할당
    String[] sArr1 = new String[3];
    String sArr2[] = new String[3];

    // 배열 초기화
    // 방법1 : 인덱스
    sArr1[0] = "a";
    sArr1[1] = "b";
    sArr1[2] = "c";

    // 방법2 : 중괄호 {} 이용
    // 선언과 동시에 초기화
//		sArr2 = {"a","b","c"}; // error : 중괄호 타입은 자료형부터 풀로 적어주는 형태에만 가능
    String[] sArr3 = {"a","b","c"};

    // 방법3 : for문
    // 배열이 int타입인 경우만 사용가능
    // 		double로 형변환 가능한 int면 for문 가능할까?  
    // 		가능. int인 i가 실수로 변환 가능한 수이기에
    int[] intArr = new int[5];
    for(int i=0; i < intArr.length;i++) {
        intArr[i] = i + 1;
    }
    for(int i=0; i < intArr.length; i++) {
        System.out.print(intArr[i]+" "); 	// 1 2 3 4 5
    }

    // 배열 삭제
    intArr = null;
    System.out.println(Arrays.toString(intArr)); // null

    // 배열 값 출력하는 방법
    //  1)for문
    //  2)Arrays.toString()

    // 1)for문
//		int[] baseArr = {1,2,3,4,5};
//		for(int i=0; i<baseArr.length;i++) {
//			System.out.print(baseArr[i] + " "); // 1 2 3 4 5
//		}
    //  2)Arrays.toString()
//		System.out.println(Arrays.toString(baseArr)); // [1, 2, 3, 4, 10]


/******************************practice 2nd ************************************/

    // 배열 선언
    char[] cArr;

    // 배열 할당
    char[] cArr1 = new char[3];
    char[] cArr2 = new char[3];

    // 배열 초기화(추가)
    // 방법1 : 인덱스
    cArr1[0] = 'a';
    cArr1[1] = 'b';
    cArr1[2] = 'c';
//		cArr1[3] = 'd';
//		System.out.println(Arrays.toString(cArr1));
    // 방법2 : 중괄호
    char[] cArr11 = {'a','b','c'};
    char[] cArr22 = {'ㄱ','ㄴ','다'};
    char[] cArr3 = {'a','b','c'};
    // 방법3 : for문
    // int배열만 사용가능
//		char[] cArr4 = new char[4];
//		for(int i=0; i < cArr4.length; i++) {
//			cArr4[i] = i + 1; // int배열만 사용가능하기에 error : Type mismatch: cannot convert from int to char
//			System.out.print(cArr4[i] + " ");
//		}

    int[] cArr4 = new int[4];
    for(int i=0; i < cArr4.length; i++) {
        cArr4[i] = i + 1;
        System.out.print(Arrays.toString(cArr4)+'\n'); // [1, 0, 0, 0][1, 2, 0, 0][1, 2, 3, 0][1, 2, 3, 4]
    }
    System.out.println(Arrays.toString(cArr4)); // [1, 2, 3, 4]

    // 배열 삭제
    cArr4 = null; 
    System.out.println(Arrays.toString(cArr4));
    System.out.println(Arrays.toString(cArr3));
    cArr3 = null;
    System.out.println(Arrays.toString(cArr3));


System.out.println("===practice 3rd===");		


/******************************practice 3rd ************************************/
    // 배열 선언
    float[] fArr;
    float[] floatArr;	// Stack 영역에 공간 생성

    // 배열 할당
    float[] fArr1 = new float[5];
    double[] dArr = new double[5];

    // 배열 초기화
    // 방법 1 : 인덱스
    dArr[0] = 0.1;
    dArr[1] = 0.2;
    dArr[2] = 3.0;
    dArr[3] = 3;	// 3.0으로 출력 -> 자동형변환
    System.out.println(Arrays.toString(dArr));

    // 방법2 : 중괄호
    double[] dArr2 = {0.1,0.2,0.3};
    System.out.println(Arrays.toString(dArr2)); // [0.1, 0.2, 0.3] -> 배열 안 값이 최대길이보다 짧으면 값만큼만 출력되서 나옴(여분공간에 다른값x)
    // 방법3 : for문
    double[] dArr3 = new double[3];
    // double로 형변환 가능한 int면 for문 가능할까?  
    // 가능. int인 i가 실수로 변환 가능한 수이기에
    for(int i=0; i < dArr3.length; i++) {
        dArr3[i] = i + 1;
        System.out.print(dArr3[i]+" "); // 1.0 2.0 3.0 
    }
    System.out.println();


    dArr3 = null;
//		for(int i = 0; i < dArr3.length; i++) {
//			System.out.println(dArr3); // null인 배열값 확인 시, for문방법은 널포인트익셉션 쓰므로 Arrays.toString() 사용해야함
//		}
    System.out.println(Arrays.toString(dArr3)); // null


}
728x90
반응형
728x90

 

row 데이터 전체 조회 및 반환 코드

내부 쿼리문

 

package com.kh.test.model.TestDao;

import java.sql.Connection;
import java.sql.Date;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.List;
import com.kh.test.model.Test;

public class TestDao {

	
	public List<Test> selectList() {
		
		List<Test> list = null;
		Connection conn = null;
		Statement stmt = null;
		ResultSet rset = null;
		
		try {
			Class.forName("Oracle.jdbc.driver.OracleDriver");
			conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.10.3:1521:xe","kh","kh");
			
			String query = "SELECT * FROM TEST";
			
			stmt = conn.createStatement();
			rset = stmt.executeQuery(query);
			
			if(rset.next()) {
				int seq = rset.getInt("SEQ");
				String writer = rset.getString("WRITER");				
				String title = rset.getString("TITLE");				
				String content = rset.getString("CONTENT");				
				Date regDate = rset.getDate("DATE");		
				
				list.add(new Test(seq, writer, title, content,regDate));
			}
		} catch (ClassNotFoundException e) {
			e.printStackTrace();	
		} catch (SQLException e) {
			e.printStackTrace();

		} finally {
			try {
				rset.close();	
				stmt.close();   
				conn.close(); 	
			} catch (SQLException e) {
				e.printStackTrace();
			} 
		}
		return list;
	}
	
}

 

 

728x90
반응형

+ Recent posts