Advertisement
Guest User

Untitled

a guest
Apr 13th, 2016
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.81 KB | None | 0 0
  1. <datasource jndi-name="java:jboss/datasources/PostgreDS" pool-name="PostgreDS" enabled="true" use-java-context="true">
  2. <connection-url>jdbc:postgresql://192.168.0.112:5432/bdns</connection-url>
  3. <driver>postgresql</driver>
  4. <transaction-isolation>TRANSACTION_READ_COMMITTED</transaction-isolation>
  5. <pool>
  6. <min-pool-size>10</min-pool-size>
  7. <max-pool-size>40</max-pool-size>
  8. <prefill>true</prefill>
  9. </pool>
  10. <security>
  11. <user-name>planosassessoria</user-name>
  12. <password>060233</password>
  13. </security>
  14. <statement>
  15. <prepared-statement-cache-size>32</prepared-statement-cache-size>
  16. <share-prepared-statements>true</share-prepared-statements>
  17. </statement>
  18. </datasource>
  19. <drivers>
  20. <driver name="postgresql" module="org.postgresql">
  21. <xa-datasource-class>org.postgresql.xa.PGXADataSource</xa-datasource-class>
  22. </driver>
  23. </drivers>
  24.  
  25. package dao;
  26.  
  27. import java.sql.Connection;
  28. import java.sql.SQLException;
  29.  
  30. import javax.naming.InitialContext;
  31. import javax.naming.NamingException;
  32. import javax.sql.DataSource;
  33.  
  34. import org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7;
  35. import org.postgresql.jdbc.PgConnection;
  36.  
  37. public class ConnectionMng {
  38. private DataSource ds;
  39.  
  40. private ConnectionMng() throws NamingException {
  41. this.ds = (DataSource)new InitialContext().lookup("java:jboss/datasources/PostgreDS");
  42. }
  43.  
  44. public PgConnection getPgConnection() throws SQLException {
  45. WrappedConnectionJDK7 wrappedConn = (WrappedConnectionJDK7)ds.getConnection();
  46. Connection underlyingConn = wrappedConn.getUnderlyingConnection();
  47. return (PgConnection)underlyingConn;
  48. }
  49. }
  50.  
  51. ClassCastException: org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7 cannot be cast to org.jboss.jca.adapters.jdbc.jdk7.WrappedConnectionJDK7
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement