1.1 --- a/java/sql-vyuka/src/java/cz/frantovo/sql/vyuka/dao/VyukaSuperDAO.java Tue Apr 23 22:07:24 2013 +0200
1.2 +++ b/java/sql-vyuka/src/java/cz/frantovo/sql/vyuka/dao/VyukaSuperDAO.java Mon Nov 09 18:57:24 2020 +0100
1.3 @@ -4,6 +4,7 @@
1.4 import java.sql.Connection;
1.5 import java.sql.SQLException;
1.6 import java.util.logging.Level;
1.7 +import javax.naming.Context;
1.8 import javax.naming.InitialContext;
1.9 import javax.naming.NamingException;
1.10 import javax.sql.DataSource;
1.11 @@ -14,7 +15,7 @@
1.12 */
1.13 public class VyukaSuperDAO extends SuperDAO {
1.14
1.15 - protected InitialContext kontext = null;
1.16 + protected Context kontext = null;
1.17
1.18 protected enum DATABAZE {
1.19
1.20 @@ -26,7 +27,12 @@
1.21
1.22 public VyukaSuperDAO() {
1.23 try {
1.24 + // v GlassFishi stačil InitialContext
1.25 + // v Tomcatu / TomEE nešlo v InitialContextu DB spojení najít:
1.26 + // javax.naming.NameNotFoundException: Name [jdbc/sqlVyuka/aplikace] is not bound in this Context. Unable to find [jdbc].)
1.27 + // Po přidání lookup("java:comp/env") funguje v TomEE.
1.28 kontext = new InitialContext();
1.29 + kontext = (Context) kontext.lookup("java:comp/env");
1.30 } catch (NamingException ex) {
1.31 log.log(Level.SEVERE, "Chyba při inicializaci kontextu", ex);
1.32 }
2.1 --- a/java/sql-vyuka/web/WEB-INF/web.xml Tue Apr 23 22:07:24 2013 +0200
2.2 +++ b/java/sql-vyuka/web/WEB-INF/web.xml Mon Nov 09 18:57:24 2020 +0100
2.3 @@ -16,4 +16,16 @@
2.4 <error-code>500</error-code>
2.5 <location>/WEB-INF/chyby/500.jsp</location>
2.6 </error-page>
2.7 + <resource-ref>
2.8 + <description>DB spojení: aplikace</description>
2.9 + <res-ref-name>jdbc/sqlVyuka/aplikace</res-ref-name>
2.10 + <res-type>javax.sql.DataSource</res-type>
2.11 + <res-auth>Container</res-auth>
2.12 + </resource-ref>
2.13 + <resource-ref>
2.14 + <description>DB spojení: pískoviště</description>
2.15 + <res-ref-name>jdbc/sqlVyuka/piskoviste</res-ref-name>
2.16 + <res-type>javax.sql.DataSource</res-type>
2.17 + <res-auth>Container</res-auth>
2.18 + </resource-ref>
2.19 </web-app>