출처 : http://levin01.tistory.com/1558
<data-sources>
<!-- MySQLDBCPSetting -->
<data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="driverClassName" value="org.gjt.mm.mysql.Driver" />
<set-property property="username" value="username" />
<set-property property="password" value="password" />
<set-property property="url" value="jdbc:mysql://localhost/test?autoReconnect=true" />
<set-property property="maxActive" value="10" />
<set-property property="maxIdle" value="30" />
<set-property property="maxWait" value="10000" />
<set-property property="defaultAutoCommit" value="true" />
<set-property property="defaultReadOnly" value="false" />
</data-source>
<!-- OracelDBCPSetting -->
<!-- data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<set-property property="username" value="username" />
<set-property property="password" value="password" />
<set-property property="url" value="jdbc:oracle:thin:@localhost:1521:SID" />
<set-property property="maxActive" value="100" />
<set-property property="maxIdle" value="30000" />
<set-property property="maxWait" value="100" />
<set-property property="defaultAutoCommit" value="true" />
</data-source -->
</data-sources>
출처 : http://levin01.tistory.com/1558
struts 1.3 이상 버전에서는..
JNDI 설정 해서 DataResource 사용하는 방법이나,
DBConnection Pool Class 하나 만들어서 사용하던지,
뭐 알아서!
<data-sources>
<!-- MySQLDBCPSetting -->
<data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="driverClassName" value="org.gjt.mm.mysql.Driver" />
<set-property property="username" value="username" />
<set-property property="password" value="password" />
<set-property property="url" value="jdbc:mysql://localhost/test?autoReconnect=true" />
<set-property property="maxActive" value="10" />
<set-property property="maxIdle" value="30" />
<set-property property="maxWait" value="10000" />
<set-property property="defaultAutoCommit" value="true" />
<set-property property="defaultReadOnly" value="false" />
</data-source>
<!-- OracelDBCPSetting -->
<!-- data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="driverClassName" value="oracle.jdbc.driver.OracleDriver" />
<set-property property="username" value="username" />
<set-property property="password" value="password" />
<set-property property="url" value="jdbc:oracle:thin:@localhost:1521:SID" />
<set-property property="maxActive" value="100" />
<set-property property="maxIdle" value="30000" />
<set-property property="maxWait" value="100" />
<set-property property="defaultAutoCommit" value="true" />
</data-source -->
</data-sources>
그다음 접속은 꼭 Action클래스 안에서 하셔야 합니다. DataSource를 가져올때 상속받은 Action클래스의 getDataSource() 메소를 사용하기 때문이죠.
DataSource ds = getDataSource(request);
그다음 나머지 처리는 일반적인 방식과 똑 같습니다^^
출처 : http://levin01.tistory.com/1558
struts 1.3 이상 버전에서는..
JNDI 설정 해서 DataResource 사용하는 방법이나,
DBConnection Pool Class 하나 만들어서 사용하던지,
뭐 알아서!
'FRAMEWORK' 카테고리의 다른 글
spring 과 Log4J 설치시 log4J.dtd 가 없다는 경고 메세지. (0) | 2012.10.01 |
---|---|
struts2 - TagLibrary (0) | 2010.09.01 |
struts2 - 액션클래스 비교. (0) | 2010.08.27 |