Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- InitialContext ctx = new InitialContext();
- DataSource ds = (DataSource) ctx.lookup("java:/comp/env/jdbc/oracledb");
- Connection connection = ds.getConnection();
- connection.setAutoCommit(false);
- return connection;
- <resource-ref>
- <res-ref-name>jdbc/oracledb</res-ref-name>
- <res-type>javax.sql.DataSource</res-type>
- <res-auth>Container</res-auth>
- </resource-ref>
- <Configure id="wac" class="org.eclipse.jetty.webapp.WebAppContext">
- <New id="myds" class="org.eclipse.jetty.plus.jndi.Resource">
- <Arg></Arg>
- <Arg>jdbc/oracledb</Arg>
- <Arg>
- <New class="com.mchange.v2.c3p0.ComboPooledDataSource">
- <Set name="driverClass">oracle.jdbc.OracleDriver</Set>
- <Set name="jdbcUrl">jdbc:oracle:thin:@SRVODA-SCAN.CAIRUNET.AD.BR:1521/WINTP</Set>
- <Set name="user">x</Set>
- <Set name="password">x</Set>
- <Set name="maxPoolSize">20</Set>
- <Set name="minPoolSize">5</Set>
- <Set name="acquireIncrement">5</Set>
- <Set name="maxIdleTime">45</Set>
- <Set name="maxIdleTimeExcessConnections">30</Set>
- <Set name="preferredTestQuery">select sysdate from dual</Set>
- </New>
- </Arg>
- </New>
- public static boolean closeConnection(Connection connection) {
- if(connection != null) {
- try {
- if(!connection.isClosed()) {
- connection.close();
- return true;
- }else {
- return false;
- }
- } catch (SQLException e) {
- e.printStackTrace();
- throw new IllegalArgumentException(e.getMessage());
- }
- }else {
- return false;
- }
- }
- <dependency>
- <groupId>com.mchange</groupId>
- <artifactId>c3p0</artifactId>
- <version>0.9.5.2</version>
- </dependency>
- <dependency>
- <groupId>com.mchange</groupId>
- <artifactId>mchange-commons-java</artifactId>
- <version>0.2.7</version>
- </dependency>
Add Comment
Please, Sign In to add comment