Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / libFMap_dataDB / src / org / gvsig / fmap / data / datastores / vectorial / db / jdbc / postgresqlbin / PostgresqlBinResource.java @ 21911

History | View | Annotate | Download (2.82 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.datastores.vectorial.db.jdbc.postgresqlbin;
32

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

    
36
import org.gvsig.fmap.data.InitializeException;
37
import org.gvsig.fmap.data.ReadException;
38
import org.gvsig.fmap.data.datastores.vectorial.db.jdbc.JDBCDriverNotFoundException;
39
import org.gvsig.fmap.data.datastores.vectorial.db.jdbc.JDBCExplorerParameter;
40
import org.gvsig.fmap.data.datastores.vectorial.db.jdbc.JDBCResource;
41
import org.gvsig.fmap.data.datastores.vectorial.db.jdbc.JDBCStoreParameters;
42

    
43
/**
44
 * @author jmvivo
45
 *
46
 */
47
public class PostgresqlBinResource extends JDBCResource {
48

    
49
        /* (non-Javadoc)
50
         * @see org.gvsig.fmap.data.datastores.vectorial.db.jdbc.JDBCResource#getConnection()
51
         */
52
        protected Connection getConnection() throws ReadException {
53
                return super.getConnection();
54
        }
55

    
56
        /**
57
         * @param params
58
         */
59
        PostgresqlBinResource(JDBCStoreParameters params) {
60
                super(params);
61
        }
62

    
63
        /**
64
         * @param params
65
         */
66
        PostgresqlBinResource(JDBCExplorerParameter params) {
67
                super(params);
68
        }
69

    
70
        /* (non-Javadoc)
71
         * @see org.gvsig.fmap.data.datastores.vectorial.db.jdbc.JDBCResource#createConnection()
72
         */
73
        protected Connection createConnection() throws ReadException {
74
                Connection conn = null;
75

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

    
84
                } catch (java.sql.SQLException e1) {
85
                        throw new InitializeException(this.getName(),e1);
86
                }
87
                return conn;
88
        }
89

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

    
97
        /* (non-Javadoc)
98
         * @see org.gvsig.fmap.data.Resource#getName()
99
         */
100
        public String getName() {
101
                return "PostgresqlBin";
102
        }
103

    
104
}
105