Statistics
| Revision:

root / trunk / extensions / extMetadata / src / org / gvsig / metadata / extended / persistence / H2Persistence.java @ 24243

History | View | Annotate | Download (2.5 KB)

1 23727 abeltran
/* 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 Geographic Information research group: http://www.geoinfo.uji.es
26
* Departamento de Lenguajes y Sistemas Inform?ticos (LSI)
27
* Universitat Jaume I
28
* {{Task}}
29
*/
30
31
32
package org.gvsig.metadata.extended.persistence;
33
34
35
import org.gvsig.metadata.extended.ExtendedMetadata;
36 24240 abeltran
import java.sql.Connection;
37
import java.sql.DriverManager;
38
import java.sql.PreparedStatement;
39
import java.sql.ResultSet;
40
import java.sql.SQLException;
41 23727 abeltran
42
43
public class H2Persistence implements MDPersistence{
44 24240 abeltran
45
        Connection conn = null;
46
47
        public H2Persistence() {
48
49 24243 abeltran
                        try {
50
                                Class.forName("org.h2.Driver");
51
                                conn = DriverManager.getConnection("jdbc:h2:~/extMetadata", "gvsig", "metadata");
52
                        } catch (ClassNotFoundException e) {
53
                                // TODO Auto-generated catch block
54
                                e.printStackTrace();
55
                        } catch (SQLException e) {
56
                                // TODO Auto-generated catch block
57
                                e.printStackTrace();
58
                        }
59 24240 abeltran
60
        }
61 23727 abeltran
62
        public boolean recoverMD(ExtendedMetadata md) {
63
                return false;
64
        }
65 24240 abeltran
66
        public boolean queryMD(String s) {
67
68
                String sql = "SELECT * FROM TEST";
69
                PreparedStatement prep;
70
                try {
71
                        prep = conn.prepareStatement(sql);
72
                        ResultSet rs = prep.executeQuery();
73
                        while (rs.next()) {
74
                                String id = rs.getString(1);
75
                                String name = rs.getString(2);
76
                                System.out.println("ID: " + id);
77
                                System.out.println("NAME: " + name);
78
                        }
79
                } catch (SQLException e) {
80
                        // TODO Auto-generated catch block
81
                        e.printStackTrace();
82
                }
83
84
                return false;
85
        }
86 23727 abeltran
87
        public boolean storeMD(ExtendedMetadata md) {
88
                return false;
89
        }
90
91 24240 abeltran
        public void createDB() {
92
93
        }
94
95 23727 abeltran
}