user 생성하기
create user keduit identified by "1234"
default tablespace users
temporary tablespace temp;
grant connect, dba to keduit;
http port 확인하고 9090번으로 변경하기
select dbms_xdb.gethttpport() from dual;
exec dbms_xdb.sethttpport(9090);
@Log4j
public class JDBCTests {
static {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
} catch (Exception e) {
e.printStackTrace();
}
}
@Test
public void testConnention() {
try (Connection conn = DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe",
"keduit",
"1234")) {
log.info(conn);
} catch (Exception e) {
fail(e.getMessage());
}
}
}
Hikari Connection Pool을 사용하기 위해 root-context에 bean 설정을 해주었다.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<bean id="hikariConfig" class="com.zaxxer.hikari.HikariConfig">
<property name="driverClassName" value="net.sf.log4jdbc.sql.jdbcapi.DriverSpy"></property>
<property name="jdbcUrl" value="jdbc:log4jdbc:oracle:thin:@localhost:1521:xe"></property>
<property name="username" value="keduit"></property>
<property name="password" value="1234"></property>
</bean>
<bean id="dataSource" class="com.zaxxer.hikari.HikariDataSource" destroy-method="close">
<constructor-arg ref="hikariConfig"></constructor-arg>
</bean>
<!-- Root Context: defines shared resources visible to all other web components -->
<context:component-scan base-package="com.keduit.sample"></context:component-scan>
</beans>