Guest User

Untitled

a guest
Aug 17th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. Tomcat JNDI Connection with MS SqlServer 2008 R2 issue
  2. <Resource name="jdbc/XXX"
  3. auth="Container"
  4. type="javax.sql.DataSource"
  5. maxActive="50"
  6. maxIdle="50"
  7. maxWait="20000"
  8. username="XX"
  9. password="XX"
  10. driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
  11. url="jdbc:sqlserver://XXX.XXX.XXX.XXX:1433;databaseName=XXX"
  12. removeAbandoned="true"
  13. removeAbandonedTimeout="1800"
  14. />
  15.  
  16. <resource-ref>
  17. <description>SQLSERVER Connection</description>
  18. <res-ref-name>jdbc/XXX</res-ref-name>
  19. <res-type>javax.sql.DataSource</res-type>
  20. <res-auth>Container</res-auth>
  21. </resource-ref>
  22.  
  23. try {
  24. Context initCtx = new InitialContext();
  25. Context envCtx = (Context) initCtx.lookup("java:comp/env");
  26. log.info("0");
  27. dsSqlServer = (DataSource) envCtx.lookup("jdbc/XXX"); <---OK
  28. log.info("1");
  29. connSqlServer = dsSqlServer.getConnection(); <---THIS DOES NOTHING, "2" IS NEVER SHOWN IN LOG FILE!!!!!!
  30. log.info("2");
  31. ...
  32. } catch (Exception e) {
  33. log.fatal("SQLSERVER: Impossibile connettersi al database: " + e);
  34. }
Add Comment
Please, Sign In to add comment