Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. <Context shallowOutput="true" path="/">
  2. <WatchedResource>WEB-INF/web.xml</WatchedResource>
  3.  
  4. <Resource name="jdbc/myDataSource"
  5. auth="Container"
  6. type="javax.sql.DataSource"
  7. factory="org.apache.commons.dbcp.BasicDataSourceFactory"
  8. driverClassName="oracle.jdbc.driver.OracleDriver"
  9. username="OMITTED"
  10. password="OMITTED"
  11. url="OMITTED"
  12. maxActive="20"
  13. maxIdle="10"
  14. maxWait="-1"/>
  15.  
  16. String db_class = DriverManager.getConnection(db_url, usr, passwd).getClass().getName();
  17.  
  18. org.postgresql.jdbc4.Jdbc4Connection
  19.  
  20. ds.getConnection().getClass().getName()
  21.  
  22. public static void show_connection_info(Connection conn)
  23. {
  24. System.out.println("Connection: " + conn);
  25. System.out.println("Connection class: " + conn.getClass());
  26. System.out.println("Connection class name: " + conn.getClass().getName());
  27. }
  28.  
  29. Connection: oracle.jdbc.driver.T4CConnection@1e1c66a
  30. Connection class: class oracle.jdbc.driver.T4CConnection
  31. Connection class name: oracle.jdbc.driver.T4CConnection
  32.  
  33. Field field = dataSource.getClass().getDeclaredField("driver");
  34. field.setAccessible(true);
  35. return field.get(dataSource).getClass().getName();
  36.  
  37. DriverManager.getDriver(ds.getConnection().getMetaData().getURL()).getClass();
  38.  
  39. if(source instanceof org.apache.tomcat.dbcp.dbcp.BasicDataSource){
  40. logger.info("Driver className: "+((org.apache.tomcat.dbcp.dbcp.BasicDataSource)source).getDriverClassName());
  41. }
  42.  
  43. <!-- https://mvnrepository.com/artifact/org.apache.tomcat/tomcat-dbcp -->
  44. <dependency><!-- to check driver name effectively running -->
  45. <scope>provided</scope>
  46. <groupId>org.apache.tomcat</groupId>
  47. <artifactId>tomcat-dbcp</artifactId>
  48. <version>7.0.47</version>
  49. </dependency>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement