programming/spring_framework

ANT를 이용한 테이블 생성

labj 2012. 3. 21. 12:23

Spring 프레임워크 워크북 - Chapter01 - 예정 실행 방법

- build.properties

...

jdbc.driverClassName=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/spring?characterEncoding=euckr
jdbc.username=javajigi
jdbc.password=password

 

- build.xml

...

<property file="build.properties" />

...

 <!-- populate the database -->
 <target name="populate">
  <echo message="Loading sample data..." />
  <sql driver="${jdbc.driverClassName}" url="${jdbc.url}" userid="${jdbc.username}" password="${jdbc.password}" src="${resources.dir}/chapter1.sql">
   <classpath refid="classpath" />
  </sql>
 </target>

 

- chapter1.sql

-- DROP TABLE USERINFO;

CREATE TABLE USERINFO ( 
 userId          varchar(12)  NOT NULL, 
 password  varchar(12)  NOT NULL,
 name   varchar(20)  NOT NULL,
 email   varchar(50),
 adminYN   tinyint(1)      NOT NULL,
   
 PRIMARY KEY               (userId),   
 INDEX USERINFO_userId_idx  (userId)
);

INSERT INTO USERINFO VALUES('admin', 'admin', '관리자', 'admin@javajigi.net', 1);
INSERT INTO USERINFO VALUES('javajigi', 'javajigi', '자바지기', 'javajigi@javajigi.net', 0);