develog

Apache Derby 설치 본문

Dev/Java

Apache Derby 설치

냐옴 2013. 8. 24. 21:05

Apache Derby 설치


▶설치 가이드

http://db.apache.org/derby/papers/DerbyTut/install_software.html


▶프로그램 다운로드

db-derby-10.10.1.1-bin.zip


▶프로그램 압축해제

C:\Apache\db-derby-10.10.1.1-bin\


▶환경변수 셋팅

DERBY_INSTALL=C:\Apache\db-derby-10.10.1.1-bin


▶CLASSPATH 추가 (derby.jar, derbytools.jar)

;%DERBY_INSTALL%\lib\derby.jar;%DERBY_INSTALL%\lib\derbytools.jar;


▶설치됐는지 확인

c:\> java org.apache.derby.tools.sysinfo


▶ij 실행

c:\> java org.apache.derby.tools.ij


▶데이터베이스 생성

ij> connect 'jdbc:derby:MyDbTest;create=true';

ij> disconnect;

ij> exit;


▶종료후 다시 실행

c:\> java -Dij.protocol=jdbc:derby: org.apache.derby.tools.ij


▶DB 접속, 테이블 생성

ij> connect 'jdbc:derby:c:/MyDbTest';

ij> create table atest (seq int, title varchar(100));

ij> insert into atest (seq, title) values (1, 'aa');

ij> insert into atest (seq, title) values (2, 'bb');

ij> insert into atest (seq, title) values (3, 'cc');

ij> select * from atest;

ij> disconnect;

ij> exit;


▶DB 실행 (별도 프로세스로 실행)

C:\Apache\db-derby-10.10.1.1-bin\bin\startNetworkServer


▶Eclipse-Java Project-Properties

Java Build Path-Add External JARs

derby.jar 추가

derbyclient.jar 추가


▶getConnection()

public Connection getConnection() throws Exception {

Connection conn = null;

try {

Class.forName("org.apache.derby.jdbc.ClientDriver");

conn = DriverManager.getConnection("jdbc:derby://localhost:1527/C:/MyDbTest");

} catch (Exception e) {

e.printStackTrace();

}

return conn;

}



'Dev > Java' 카테고리의 다른 글

quartz, Cron Expressions  (0) 2013.09.05
quartz  (0) 2013.09.05
java file copy test  (0) 2013.08.21
[Maven] pom.xml  (0) 2013.08.13
[java] spring, mybatis config  (0) 2013.08.13
Comments