Revision 11928 branches/v10/libraries/libFMap/src/com/iver/cit/gvsig/fmap/layers/LayerFactory.java

View differences:

LayerFactory.java
72 72
import com.iver.cit.gvsig.fmap.LegendDriverExceptionType;
73 73
import com.iver.cit.gvsig.fmap.ProgressListener;
74 74
import com.iver.cit.gvsig.fmap.ViewPort;
75
import com.iver.cit.gvsig.fmap.drivers.ConnectionFactory;
76
import com.iver.cit.gvsig.fmap.drivers.DBException;
75 77
import com.iver.cit.gvsig.fmap.drivers.DBLayerDefinition;
76 78
import com.iver.cit.gvsig.fmap.drivers.DriverIOException;
79
import com.iver.cit.gvsig.fmap.drivers.IConnection;
77 80
import com.iver.cit.gvsig.fmap.drivers.RasterDriver;
78
import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver;
81
import com.iver.cit.gvsig.fmap.drivers.IVectorialDatabaseDriver;
79 82
import com.iver.cit.gvsig.fmap.drivers.VectorialDriver;
80 83
import com.iver.cit.gvsig.fmap.drivers.VectorialFileDriver;
81
import com.iver.cit.gvsig.fmap.drivers.VectorialJDBCDriver;
84
import com.iver.cit.gvsig.fmap.drivers.IVectorialJDBCDriver;
82 85
import com.iver.cit.gvsig.fmap.drivers.WithDefaultLegend;
83 86
import com.iver.cit.gvsig.fmap.operations.arcview.ArcJoin;
84 87
import com.iver.cit.gvsig.fmap.rendering.LegendFactory;
......
267 270
		if (d instanceof VectorialFileDriver) {
268 271
			adapter = new VectorialFileAdapter(((VectorialFileDriver) d)
269 272
					.getFile());
270
		} else if (d instanceof VectorialJDBCDriver) {
273
		} else if (d instanceof IVectorialJDBCDriver) {
271 274
			adapter = new VectorialDBAdapter();
272 275
		} else {
273 276
			adapter = new VectorialDefaultAdapter();
......
462 465
	}
463 466

  
464 467
	public static FLayer createArcSDELayer(String layerName,
465
			VectorialDatabaseDriver driver, IProjection proj) {
468
			IVectorialDatabaseDriver driver, IProjection proj) {
466 469
		// throw new UnsupportedOperationException();
467 470
		FLyrVect layer = new FLyrVect();
468 471
		VectorialAdapter adapter = new VectorialDBAdapter();
......
518 521
	 *
519 522
	 * @throws UnsupportedOperationException
520 523
	 */
521
	public static FLayer createLayer(VectorialDatabaseDriver driver,
524
	public static FLayer createLayer(IVectorialDatabaseDriver driver,
522 525
			String host, int port, String user, String password, String dbName,
523 526
			String tableName, IProjection proj) {
524 527
		throw new UnsupportedOperationException();
525 528
	}
526 529

  
527
	public static FLayer createDBLayer(VectorialDatabaseDriver driver,
530
	public static FLayer createDBLayer(IVectorialDatabaseDriver driver,
528 531
			String layerName, IProjection proj) {
529 532

  
530 533
		FLyrVect capa = new FLyrVect();
......
612 615
	 * @throws ClassNotFoundException
613 616
	 * @throws
614 617
	 */
615
	public static FLayer createDisconnectedDBLayer(VectorialJDBCDriver driver,
618
	public static FLayer createDisconnectedDBLayer(IVectorialDatabaseDriver driver,
616 619
			String layerName, IProjection proj, ProgressListener listener)
617
			throws SQLException, IOException, DriverIOException,
620
			throws DBException, IOException, DriverIOException,
618 621
			DriverLoadException, NoSuchTableException,
619 622
			com.hardcode.gdbms.engine.data.driver.DriverException,
620 623
			ClassNotFoundException {
......
632 635
		for (int i = 1; i < types.length; i++) {
633 636
			types[i] = ds.getFieldType(i - 1);
634 637
		}
635
		String dsName = dataSourceFactory.createTable(database,
636
				ds.getPKNames(), fieldNames, types);
638
		String dsName=null;
639
		try {
640
			dsName = dataSourceFactory.createTable(database,
641
					ds.getPKNames(), fieldNames, types);
642
		} catch (SQLException e) {
643
			throw new DBException(e);
644
		}
637 645

  
638 646
		DBLayerDefinition lyrDef = new DBLayerDefinition();
639 647
		lyrDef.setTableName(dsName);
......
686 694
		dw.stop();
687 695
		local.stop();
688 696
		ds.stop();
689
		VectorialJDBCDriver cacheDriver = (VectorialJDBCDriver) LayerFactory
697
		IVectorialJDBCDriver cacheDriver = (IVectorialJDBCDriver) LayerFactory
690 698
				.getDM().getDriver("HSQLDB Driver");
691 699
		Class.forName("org.hsqldb.jdbcDriver");
692

  
693
		cacheDriver.setData(java.sql.DriverManager.getConnection(
694
				"jdbc:hsqldb:file:" + database, "sa", ""), lyrDef);
700
		IConnection conn=ConnectionFactory.createConnection("jdbc:hsqldb:file:" + database, "sa", "");
701
		cacheDriver.setData(conn, lyrDef);
695 702
		cacheDriver.setWorkingArea(driver.getWorkingArea());
696 703
		return createDBLayer(cacheDriver, layerName, proj);
697 704
	}

Also available in: Unified diff