Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_dataDB / src / org / gvsig / fmap / data / feature / db / jdbc / h2 / H2Resource.java @ 22373

History | View | Annotate | Download (2.8 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
*
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
* MA  02110-1301, USA.
20
*
21
*/
22

    
23
/*
24
* AUTHORS (In addition to CIT):
25
* 2008 IVER T.I   {{Task}}
26
*/
27

    
28
/**
29
 *
30
 */
31
package org.gvsig.fmap.data.feature.db.jdbc.h2;
32

    
33
import java.sql.Connection;
34
import java.sql.DriverManager;
35

    
36
import org.gvsig.fmap.data.DataException;
37
import org.gvsig.fmap.data.InitializeException;
38
import org.gvsig.fmap.data.OpenException;
39
import org.gvsig.fmap.data.ReadException;
40
import org.gvsig.fmap.data.ResourceChangedException;
41
import org.gvsig.fmap.data.feature.db.jdbc.JDBCDriverNotFoundException;
42
import org.gvsig.fmap.data.feature.db.jdbc.JDBCExplorerParameter;
43
import org.gvsig.fmap.data.feature.db.jdbc.JDBCResource;
44
import org.gvsig.fmap.data.feature.db.jdbc.JDBCStoreParameters;
45

    
46
/**
47
 * @author jmvivo
48
 *
49
 */
50
public class H2Resource extends JDBCResource {
51

    
52
        /* (non-Javadoc)
53
         * @see org.gvsig.fmap.data.feature.db.jdbc.JDBCResource#getConnection()
54
         */
55
        protected Connection getConnection() throws ReadException {
56
                return super.getConnection();
57
        }
58

    
59
        /**
60
         * @param params
61
         */
62
        H2Resource(JDBCStoreParameters params) {
63
                super(params);
64
        }
65

    
66
        /**
67
         * @param params
68
         */
69
        H2Resource(JDBCExplorerParameter params) {
70
                super(params);
71
        }
72

    
73
        /* (non-Javadoc)
74
         * @see org.gvsig.fmap.data.feature.db.jdbc.JDBCResource#createConnection()
75
         */
76
        protected Connection createConnection() throws ReadException {
77
                Connection conn = null;
78

    
79
                try {
80
                        Class.forName("org.h2.Driver");
81
                } catch (ClassNotFoundException e) {
82
                        throw new JDBCDriverNotFoundException("org.h2.Driver",e);
83
                }
84
                try {
85
                        conn = DriverManager.getConnection(this.getUrl(), this.getUser(), this.getPassword());
86

    
87
                } catch (java.sql.SQLException e1) {
88
                        throw new InitializeException(this.getName(),e1);
89
                }
90
                return conn;
91
        }
92

    
93
        /* (non-Javadoc)
94
         * @see org.gvsig.fmap.data.Resource#generateKey()
95
         */
96
        protected String generateKey() {
97
                return this.getName()+";"+this.getUrl()+";"+this.getUser();
98
        }
99

    
100
        /* (non-Javadoc)
101
         * @see org.gvsig.fmap.data.Resource#getName()
102
         */
103
        public String getName() {
104
                return "h2";
105
        }
106

    
107
}
108