develog

[Spring] dbcp 설정 본문

Dev/Java

[Spring] dbcp 설정

냐옴 2014. 8. 8. 11:01

jar

 tomcat-dbcp.jar


beans.xml

<bean id="dataSource" class="org.apache.tomcat.dbcp.dbcp.BasicDataSource">

    <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver" />

    <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl" />

    <property name="username" value="scott" />

    <property name="password" value="tiger" />

</bean>


soruce

ApplicationContext context = new ClassPathXmlApplicationContext("classpath:beans.xml");

DataSource ds = (DataSource) context.getBean("dataSource");

Connection conn = ds.getConnection();

System.out.println(conn);

conn.close();


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

eclipse.ini  (0) 2014.09.10
[Java] 익명 PL/SQL 블럭 실행  (0) 2014.08.29
[Java] byte <-> int  (0) 2014.07.27
[Java] bit & shift 연산  (0) 2014.07.26
byte, int, 한글  (0) 2014.07.26
Comments