Changeset 86:a51bbc91a4cb
- Timestamp:
- 11/09/20 18:57:24 (4 years ago)
- Author:
- František Kučera <franta-hg@…>
- Branch:
- default
- Message:
-
zprovoznění v aplikačním serveru Tomcat / TomEE
- Location:
- java/sql-vyuka
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
r33
|
r86
|
|
5 | 5 | import java.sql.SQLException; |
6 | 6 | import java.util.logging.Level; |
| 7 | import javax.naming.Context; |
7 | 8 | import javax.naming.InitialContext; |
8 | 9 | import javax.naming.NamingException; |
… |
… |
|
15 | 16 | public class VyukaSuperDAO extends SuperDAO { |
16 | 17 | |
17 | | protected InitialContext kontext = null; |
| 18 | protected Context kontext = null; |
18 | 19 | |
19 | 20 | protected enum DATABAZE { |
… |
… |
|
27 | 28 | public VyukaSuperDAO() { |
28 | 29 | try { |
| 30 | // v GlassFishi stačil InitialContext |
| 31 | // v Tomcatu / TomEE nešlo v InitialContextu DB spojení najít: |
| 32 | // javax.naming.NameNotFoundException: Name [jdbc/sqlVyuka/aplikace] is not bound in this Context. Unable to find [jdbc].) |
| 33 | // Po přidání lookup("java:comp/env") funguje v TomEE. |
29 | 34 | kontext = new InitialContext(); |
| 35 | kontext = (Context) kontext.lookup("java:comp/env"); |
30 | 36 | } catch (NamingException ex) { |
31 | 37 | log.log(Level.SEVERE, "Chyba při inicializaci kontextu", ex); |
-
r74
|
r86
|
|
17 | 17 | <location>/WEB-INF/chyby/500.jsp</location> |
18 | 18 | </error-page> |
| 19 | <resource-ref> |
| 20 | <description>DB spojení: aplikace</description> |
| 21 | <res-ref-name>jdbc/sqlVyuka/aplikace</res-ref-name> |
| 22 | <res-type>javax.sql.DataSource</res-type> |
| 23 | <res-auth>Container</res-auth> |
| 24 | </resource-ref> |
| 25 | <resource-ref> |
| 26 | <description>DB spojení: pískoviště</description> |
| 27 | <res-ref-name>jdbc/sqlVyuka/piskoviste</res-ref-name> |
| 28 | <res-type>javax.sql.DataSource</res-type> |
| 29 | <res-auth>Container</res-auth> |
| 30 | </resource-ref> |
19 | 31 | </web-app> |