/[projects]/dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/db/DBConnection.java
ViewVC logotype

Contents of /dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/db/DBConnection.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3023 - (show annotations) (download)
Tue Apr 26 18:57:25 2016 UTC (8 years ago) by torben
File size: 1216 byte(s)
Use batch inserts with on duplicate key update, in order to speedup updates
1 package dk.daoas.adressevedligehold.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?rewriteBatchedStatements=true" username="import"
23
24 testOnBorrow="true"
25 validationQuery="SELECT 1"
26
27 />
28
29 */
30
31 public class DBConnection {
32 public static Connection getConnection() throws SQLException{
33 try {
34
35 Context initContext = new InitialContext();
36 Context envContext = (Context)initContext.lookup("java:/comp/env");
37
38 DataSource ds = (DataSource) envContext.lookup("jdbc/fulddaekning");
39 return ds.getConnection();
40 } catch (NamingException e) {
41 throw new SQLException("invalid data source: " +e.getMessage(), e);
42 }
43 }
44 }

  ViewVC Help
Powered by ViewVC 1.1.20