Revision 12351 branches/v10/extensions/extJDBC/src/com/iver/cit/gvsig/fmap/drivers/jdbc/postgis/PostGisDriver.java

View differences:

PostGisDriver.java
44 44
package com.iver.cit.gvsig.fmap.drivers.jdbc.postgis;
45 45

  
46 46
import java.awt.geom.Rectangle2D;
47
import java.io.IOException;
47 48
import java.math.BigDecimal;
48 49
import java.nio.ByteBuffer;
49 50
import java.sql.Connection;
......
169 170
	}
170 171

  
171 172
	/**
173
	 * @throws IOException
172 174
	 * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getShape(int)
173 175
	 */
174
	public IGeometry getShape(int index) {
176
	public IGeometry getShape(int index) throws IOException {
175 177
		IGeometry geom = null;
176 178
		boolean resul;
177 179
		try {
......
185 187
				geom = parser.parse(data);
186 188
			}
187 189
		} catch (SQLException e) {
188
			e.printStackTrace();
190
			throw new IOException(e.getMessage());
189 191
		}
190 192

  
191 193
		return geom;
......
208 210
	 * quiere usar.
209 211
	 *
210 212
	 * @param conn
213
	 * @throws DBException
211 214
	 */
212
	public void setData(IConnection conn, DBLayerDefinition lyrDef) {
215
	public void setData(IConnection conn, DBLayerDefinition lyrDef) throws DBException {
213 216
		this.conn = conn;
214 217
		// TODO: Deber?amos poder quitar Conneciton de la llamada y meterlo
215 218
		// en lyrDef desde el principio.
......
258 261

  
259 262

  
260 263
		} catch (SQLException e) {
261
			e.printStackTrace();
262
			NotificationManager.addError(
263
					"Error al conectar a la base de datos.", e);
264
			throw new DBException(e);
264 265
		} catch (EditionException e) {
265
			e.printStackTrace();
266
			NotificationManager.addError(
267
					"Error inicializando PosGIS Writer.", e);
266
			throw new DBException(e);
268 267

  
269 268
		}
270 269
	}
271 270

  
272 271
	/**
272
	 * @throws IOException
273 273
	 * @see com.iver.cit.gvsig.fmap.layers.ReadableVectorial#getFullExtent()
274 274
	 */
275
	public Rectangle2D getFullExtent() {
275
	public Rectangle2D getFullExtent() throws IOException {
276 276
		if (fullExtent == null) {
277 277
			try {
278 278
				Statement s = ((ConnectionJDBC)conn).getConnection().createStatement();
......
304 304
					fullExtent = new Rectangle2D.Double(x, y, w, h);
305 305
				}
306 306
			} catch (SQLException e) {
307
				System.err.println(e.getMessage());
307
				throw new IOException(e.getMessage());
308 308
			}
309 309

  
310 310
		}
......
341 341
			geomIterator.setLyrDef(getLyrDef());
342 342
		} catch (SQLException e) {
343 343
			e.printStackTrace();
344
			e.printStackTrace();
345 344
			SqlDriveExceptionType type = new SqlDriveExceptionType();
346 345
            type.setDriverName("PostGIS Driver");
347 346
            type.setSql(sql);
......
681 680
	 *
682 681
	 * @see com.iver.cit.gvsig.fmap.drivers.DefaultDBDriver#doRelateID_FID()
683 682
	 */
684
	protected void doRelateID_FID() {
683
	protected void doRelateID_FID() throws DBException {
685 684
		hashRelate = new Hashtable();
686 685
		try {
687 686
			String strSQL = "SELECT " + getLyrDef().getFieldID() + " FROM "
......
733 732
			 * TODO Auto-generated catch block e.printStackTrace();
734 733
			 */
735 734
		} catch (SQLException e) {
736
			// TODO Auto-generated catch block
737
			e.printStackTrace();
735
			throw new DBException(e);
738 736
		}
739 737
	}
740 738

  
......
905 903
		}
906 904
		return (String[]) list.toArray(new String[0]);
907 905
	}
908
	public String[] getTableFields(IConnection conex, String table) throws DBException {
909
		try{
910
		Statement st = ((ConnectionJDBC)conex).getConnection().createStatement();
911
        // ResultSet rs = dbmd.getTables(catalog, null, dbLayerDefinition.getTable(), null);
912
		ResultSet rs = st.executeQuery("select * from " + table + " LIMIT 1");
913
		ResultSetMetaData rsmd = rs.getMetaData();
906
//	public String[] getTableFields(IConnection conex, String table) throws DBException {
907
//		try{
908
//		Statement st = ((ConnectionJDBC)conex).getConnection().createStatement();
909
//        // ResultSet rs = dbmd.getTables(catalog, null, dbLayerDefinition.getTable(), null);
910
//		ResultSet rs = st.executeQuery("select * from " + table + " LIMIT 1");
911
//		ResultSetMetaData rsmd = rs.getMetaData();
912
//
913
//		String[] ret = new String[rsmd.getColumnCount()];
914
//
915
//		for (int i = 0; i < ret.length; i++) {
916
//			ret[i] = rsmd.getColumnName(i+1);
917
//		}
918
//
919
//		return ret;
920
//		}catch (SQLException e) {
921
//			throw new DBException(e);
922
//		}
923
//	}
924
//	public String[] getTableNames(IConnection conn, String catalog) throws DBException {
925
//		// TODO Auto-generated method stub
926
//		return super.getTableNames(conn, catalog);
927
//	}
914 928

  
915
		String[] ret = new String[rsmd.getColumnCount()];
916

  
917
		for (int i = 0; i < ret.length; i++) {
918
			ret[i] = rsmd.getColumnName(i+1);
919
		}
920

  
921
		return ret;
922
		}catch (SQLException e) {
923
			throw new DBException(e);
924
		}
925
	}
926
	public String[] getTableNames(IConnection conn, String catalog) throws DBException {
927
		// TODO Auto-generated method stub
928
		return super.getTableNames(conn, catalog);
929
	}
930

  
931 929
}

Also available in: Unified diff