Guest User

Untitled

a guest
Oct 25th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. InitialContext ctx = new InitialContext();
  2. DataSource ds = (DataSource) ctx.lookup("java:/comp/env/jdbc/oracledb");
  3. Connection connection = ds.getConnection();
  4. connection.setAutoCommit(false);
  5. return connection;
  6.  
  7. <resource-ref>
  8. <res-ref-name>jdbc/oracledb</res-ref-name>
  9. <res-type>javax.sql.DataSource</res-type>
  10. <res-auth>Container</res-auth>
  11. </resource-ref>
  12.  
  13. <Configure id="wac" class="org.eclipse.jetty.webapp.WebAppContext">
  14. <New id="myds" class="org.eclipse.jetty.plus.jndi.Resource">
  15. <Arg></Arg>
  16. <Arg>jdbc/oracledb</Arg>
  17. <Arg>
  18.  
  19. <New class="com.mchange.v2.c3p0.ComboPooledDataSource">
  20. <Set name="driverClass">oracle.jdbc.OracleDriver</Set>
  21. <Set name="jdbcUrl">jdbc:oracle:thin:@SRVODA-SCAN.CAIRUNET.AD.BR:1521/WINTP</Set>
  22. <Set name="user">x</Set>
  23. <Set name="password">x</Set>
  24. <Set name="maxPoolSize">20</Set>
  25. <Set name="minPoolSize">5</Set>
  26. <Set name="acquireIncrement">5</Set>
  27. <Set name="maxIdleTime">45</Set>
  28. <Set name="maxIdleTimeExcessConnections">30</Set>
  29. <Set name="preferredTestQuery">select sysdate from dual</Set>
  30.  
  31. </New>
  32.  
  33. </Arg>
  34. </New>
  35.  
  36. public static boolean closeConnection(Connection connection) {
  37.  
  38. if(connection != null) {
  39. try {
  40. if(!connection.isClosed()) {
  41. connection.close();
  42. return true;
  43. }else {
  44. return false;
  45. }
  46.  
  47. } catch (SQLException e) {
  48. e.printStackTrace();
  49. throw new IllegalArgumentException(e.getMessage());
  50. }
  51. }else {
  52. return false;
  53. }
  54. }
  55.  
  56. <dependency>
  57. <groupId>com.mchange</groupId>
  58. <artifactId>c3p0</artifactId>
  59. <version>0.9.5.2</version>
  60. </dependency>
  61.  
  62. <dependency>
  63. <groupId>com.mchange</groupId>
  64. <artifactId>mchange-commons-java</artifactId>
  65. <version>0.2.7</version>
  66. </dependency>
Add Comment
Please, Sign In to add comment