Revision 10626 trunk/extensions/extJDBC/src/com/iver/cit/gvsig/fmap/drivers/jdbc/hsqldb/HSQLDBFeatureIterator.java

View differences:

HSQLDBFeatureIterator.java
2 2
 * Created on 11-mar-2005
3 3
 *
4 4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 * 
5
 *
6 6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 * 
7
 *
8 8
 * This program is free software; you can redistribute it and/or
9 9
 * modify it under the terms of the GNU General Public License
10 10
 * as published by the Free Software Foundation; either version 2
11 11
 * of the License, or (at your option) any later version.
12
 *  
12
 *
13 13
 * This program is distributed in the hope that it will be useful,
14 14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 16
 * GNU General Public License for more details.
17
 * 
17
 *
18 18
 * You should have received a copy of the GNU General Public License
19 19
 * along with this program; if not, write to the Free Software
20 20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21
 *  
21
 *
22 22
 * For more information, contact:
23 23
 *
24 24
 *  Generalitat Valenciana
......
30 30
 *      +34 963862235
31 31
 *   gvsig@gva.es
32 32
 *      www.gvsig.gva.es
33
 * 
33
 *
34 34
 *    or
35
 * 
35
 *
36 36
 *   IVER T.I. S.A
37 37
 *   Salamanca 50
38 38
 *   46005 Valencia
39 39
 *   Spain
40
 * 
40
 *
41 41
 *   +34 963163400
42 42
 *   dac@iver.es
43 43
 */
......
48 48
import java.sql.SQLException;
49 49
import java.sql.Types;
50 50

  
51
import com.hardcode.gdbms.driver.exceptions.ReadDriverException;
51 52
import com.hardcode.gdbms.engine.values.Value;
52 53
import com.hardcode.gdbms.engine.values.ValueFactory;
53
import com.iver.cit.gvsig.fmap.DriverException;
54 54
import com.iver.cit.gvsig.fmap.SqlDriveExceptionType;
55 55
import com.iver.cit.gvsig.fmap.core.DefaultFeature;
56 56
import com.iver.cit.gvsig.fmap.core.IFeature;
......
60 60

  
61 61
/**
62 62
 * @author FJP
63
 * 
63
 *
64 64
 * TODO To change the template for this generated type comment go to Window -
65 65
 * Preferences - Java - Code Generation - Code and Comments
66 66
 */
......
81 81

  
82 82
	/**
83 83
	 * @throws SQLException
84
	 * 
84
	 *
85 85
	 */
86 86
	public HSQLDBFeatureIterator(ResultSet rs) {
87 87
		// Debe ser forward only
......
98 98

  
99 99
	/*
100 100
	 * (non-Javadoc)
101
	 * 
101
	 *
102 102
	 * @see com.iver.cit.gvsig.fmap.drivers.jdbc.GeometryIterator#hasNext()
103 103
	 */
104
	public boolean hasNext() throws DriverException {
104
	public boolean hasNext() throws ReadDriverException {
105 105
		try {
106 106
			if (rs.isLast()) {
107 107
				rs.close();
108 108
				return false;
109
			} else
110
				return true;
111
		} catch (SQLException e) {
112
			SqlDriveExceptionType type = new SqlDriveExceptionType();
113
            type.setDriverName("HSQLDB Driver");
114
            try {
115
				type.setSql(rs.getStatement().toString());
116
			} catch (SQLException e1) {
117
				e1.printStackTrace();
118 109
			}
119
            throw new com.iver.cit.gvsig.fmap.DriverException(e, type);
120
//			throw new DriverException(e);
110
			return true;
111
		} catch (SQLException e) {
112
//			SqlDriveExceptionType type = new SqlDriveExceptionType();
113
//            type.setDriverName("HSQLDB Driver");
114
//            try {
115
//				type.setSql(rs.getStatement().toString());
116
//			} catch (SQLException e1) {
117
//				e1.printStackTrace();
118
//			}
119
            throw new ReadDriverException("HSQLDB Driver",e);
121 120
		}
122 121
	}
123 122

  
124 123
	/*
125 124
	 * (non-Javadoc)
126
	 * 
125
	 *
127 126
	 * @see com.iver.cit.gvsig.fmap.drivers.jdbc.GeometryIterator#next()
128 127
	 */
129
	public IFeature next() throws DriverException {
128
	public IFeature next() throws ReadDriverException {
130 129
		try {
131 130
			rs.next();
132 131
			byte[] data = rs.getBytes(1);
......
165 164

  
166 165
			return feat;
167 166
		} catch (SQLException e) {
168
			SqlDriveExceptionType type = new SqlDriveExceptionType();
169
            type.setDriverName("HSQLDB Driver");
170
            try {
171
				type.setSql(rs.getStatement().toString());
172
			} catch (SQLException e1) {
173
				e1.printStackTrace();
174
			}
175
            throw new com.iver.cit.gvsig.fmap.DriverException(e, type);
167
//			SqlDriveExceptionType type = new SqlDriveExceptionType();
168
//            type.setDriverName("HSQLDB Driver");
169
//            try {
170
//				type.setSql(rs.getStatement().toString());
171
//			} catch (SQLException e1) {
172
//				e1.printStackTrace();
173
//			}
174
            throw new ReadDriverException("HSQLDB Driver",e);
176 175
		}
177 176

  
178 177
	}
179 178

  
180 179
	/*
181 180
	 * (non-Javadoc)
182
	 * 
181
	 *
183 182
	 * @see com.iver.cit.gvsig.fmap.drivers.IFeatureIterator#closeIterator()
184 183
	 */
185
	public void closeIterator() throws DriverException {
184
	public void closeIterator() throws ReadDriverException {
186 185
		try {
187 186
			rs.close();
188 187
		} catch (SQLException e) {
189
			SqlDriveExceptionType type = new SqlDriveExceptionType();
190
            type.setDriverName("HSQLDB Driver");
191
            try {
192
				type.setSql(rs.getStatement().toString());
193
			} catch (SQLException e1) {
194
				e1.printStackTrace();
195
			}
196
            throw new com.iver.cit.gvsig.fmap.DriverException(e, type);
188
//			SqlDriveExceptionType type = new SqlDriveExceptionType();
189
//            type.setDriverName("HSQLDB Driver");
190
//            try {
191
//				type.setSql(rs.getStatement().toString());
192
//			} catch (SQLException e1) {
193
//				e1.printStackTrace();
194
//			}
195
            throw new ReadDriverException("HSQLDB Driver",e);
197 196
//			throw new DriverException(e);
198 197
		}
199 198
	}

Also available in: Unified diff