/[projects]/dao/DaoAdresseService/src/dk/daoas/daoadresseservice/db/DBConnection.java
ViewVC logotype

Annotation of /dao/DaoAdresseService/src/dk/daoas/daoadresseservice/db/DBConnection.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2267 - (hide annotations) (download)
Thu Feb 12 13:57:32 2015 UTC (9 years, 3 months ago) by torben
File size: 1099 byte(s)
Initial import.
1 torben 2267 package dk.daoas.daoadresseservice.db;
2    
3     import java.sql.Connection;
4     import java.sql.SQLException;
5    
6     import javax.naming.Context;
7     import javax.naming.InitialContext;
8     import javax.naming.NamingException;
9     import javax.sql.DataSource;
10    
11     /*
12     Husk at tilføje denne til {TOMCAT}/conf/context.xml og tilrette password.
13    
14     <Resource auth="Container"
15     driverClassName="com.mysql.jdbc.Driver"
16     maxActive="10"
17     maxIdle="5"
18     maxWait="10000"
19     name="jdbc/fulddaekning"
20     password=""
21     type="javax.sql.DataSource"
22     url="jdbc:mysql://10.30.2.51:3306/fulddaekning" username="import"/>
23    
24     */
25    
26     public class DBConnection {
27     public static Connection getConnection() throws SQLException{
28     try {
29    
30     Context initContext = new InitialContext();
31     Context envContext = (Context)initContext.lookup("java:/comp/env");
32    
33     DataSource ds = (DataSource) envContext.lookup("jdbc/fulddaekning");
34     return ds.getConnection();
35     } catch (NamingException e) {
36     throw new SQLException("invalid data source: " +e.getMessage(), e);
37     }
38     }
39     }

  ViewVC Help
Powered by ViewVC 1.1.20