Revision 34778

View differences:

branches/gvSIG_1.11.0_Mejoras_gvSIG-EIEL/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/table/gui/DataBaseOpenDialog.java
52 52
import java.awt.event.KeyEvent;
53 53
import java.awt.event.KeyListener;
54 54
import java.awt.geom.Rectangle2D;
55
import java.sql.DatabaseMetaData;
55 56
import java.sql.ResultSet;
56 57
import java.sql.SQLException;
57 58
import java.sql.Types;
......
457 458
			throw new SQLException("Unknown connection type: " + conex.getClass().getName());
458 459
		}
459 460
		
460
		String[] ret_types = {"TABLE", "VIEW"};
461
		String[] ret_types = {"TABLE", "VIEW", "SYSTEM TABLE" /* odbc */ };
461 462
		ResultSet rs = null;
462 463

  
463 464
		try {
465
			
466
//		    DatabaseMetaData dmd = jdbc_conn.getConnection().getMetaData();
467
//		    ResultSet rs2 = dmd.getTables(null, null, "%", null);
468
//		    while (rs2.next())
469
//		        System.out.println(rs2.getString(3) + " " + rs2.getString(4));
470
//		    rs2 = dmd.getTables(null, null, null, null);
471
//		    int colcnt = rs2.getMetaData().getColumnCount();
472
//		    while (rs2.next()) {
473
//		    	for (int i=0; i<colcnt; i++) {
474
//		    		System.out.println(rs2.getMetaData().getColumnName(i+1) + " : " + rs2.getString(i+1));
475
//		    	}
476
//		    }
477

  
478
			// jdbc_conn.getConnection().getMetaData().
464 479
			rs = jdbc_conn.getConnection().getMetaData().getTables(
465 480
					null,
466 481
					src.getSchema().length() == 0 ? null : src.getSchema(),
......
640 655
			if (lm.getElementAt(i) instanceof TablesListItemSimple) {
641 656
				item = (TablesListItemSimple) lm.getElementAt(i);
642 657
				if (item.isSelected()) {
643
					return item.getTableName();
658
					return quoteTableName(item.getTableName());
644 659
				}
645 660
			}
646 661
		}
......
659 674
			ConnectionJDBC conn = (ConnectionJDBC) iconn;
660 675
			AlphanumericDBDriver alpha_drv = (AlphanumericDBDriver) drv;
661 676
			
662
			tn = acttab.getTableName();
677
			tn = quoteTableName(acttab.getTableName());
663 678

  
664 679
			String _sql = "SELECT * FROM " + tn + " WHERE (0=1)";
665 680
			FieldDescription[] fd = null;
......
802 817
		getFieldsScrollPane().updateUI();
803 818
	}
804 819

  
820
	
821
	public static String quoteTableName(String _tn) {
822

  
823
		String[] pointspl = _tn.split("\\.");
824
		String resp = "";
825
		for (int i=0; i<pointspl.length; i++) {
826
			if (i!=0) {
827
				resp = resp + ".";
828
			}
829
			resp = resp + "\"" + pointspl[i] + "\"";
830
		}
831
		return resp;
832
	}
805 833
    
806 834
    
807 835

  
branches/gvSIG_1.11.0_Mejoras_gvSIG-EIEL/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/ConnectionJDBC.java
46 46
import java.sql.DriverManager;
47 47
import java.sql.SQLException;
48 48

  
49
import org.apache.log4j.Logger;
49 50

  
51

  
50 52
/**
51 53
 * DOCUMENT ME!
52 54
 *
53 55
 * @author Vicente Caballero Navarro
54 56
 */
55 57
public class ConnectionJDBC implements IConnection {
58
	
59
	private static Logger logger = Logger.getLogger(ConnectionJDBC.class.getName());
56 60
    private Connection connection;
57 61
	private String connectionStr;
58 62
	private String user;
......
137 141

  
138 142
	}
139 143
	
144
	
140 145

  
141 146
	public void setDataConnection(Connection _conn, String user, String _pw) throws DBException {
147
		connection = _conn;
142 148
		try {
143
			connection = _conn;
144 149
			connection.setAutoCommit(false);
145
			this.connectionStr = null;
146
			this.user = user;
147
			this._pw = _pw;
148
		} catch (SQLException e) {
149
			throw new DBException(e);
150
		} catch (Exception ex) {
151
			logger.error("Autocommit not allowed for this driver: " + ex.getMessage());
150 152
		}
151

  
153
		this.connectionStr = null;
154
		this.user = user;
155
		this._pw = _pw;
152 156
	}
153 157

  
154 158
	/**
branches/gvSIG_1.11.0_Mejoras_gvSIG-EIEL/libraries/libFMap/src/com/iver/cit/gvsig/fmap/drivers/DefaultJDBCDriver.java
616 616
			}
617 617

  
618 618
			newConn = cwp.getConnection();
619
			//((ConnectionJDBC)newConn).getConnection().setAutoCommit(false);
620 619

  
621 620
			DBLayerDefinition lyrDef = new DBLayerDefinition();
622 621
			if (getLyrDef() == null) {
branches/gvSIG_1.11.0_Mejoras_gvSIG-EIEL/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/writers/JdbcWriter.java
5 5
import java.sql.ResultSetMetaData;
6 6
import java.sql.SQLException;
7 7

  
8
import org.apache.log4j.Logger;
9

  
10
import sun.jdbc.odbc.JdbcOdbcConnection;
11

  
8 12
import com.hardcode.gdbms.engine.values.Value;
9 13
import com.iver.cit.gvsig.exceptions.visitors.ProcessWriterVisitorException;
10 14
import com.iver.cit.gvsig.exceptions.visitors.StartWriterVisitorException;
......
12 16
import com.iver.cit.gvsig.fmap.core.IRow;
13 17
import com.iver.cit.gvsig.fmap.drivers.XTypes;
14 18
import com.iver.cit.gvsig.fmap.edition.IRowEdited;
19
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource;
15 20

  
16 21
public class JdbcWriter extends AbstractWriter {
22
	
23
	private static Logger logger = Logger.getLogger(JdbcWriter.class.getName());
24
	
17 25
	Connection conn;
18 26
	ResultSet rs;
19 27
	Value[] record;
......
36 44
			try {
37 45
				conn.setAutoCommit(false);
38 46
			} catch (SQLException e) {
39
				throw new StartWriterVisitorException(getName(),e);
47
				if (conn instanceof JdbcOdbcConnection) {
48
					logger.warn("Driver does not allow autocommit method: " + conn.getClass().getName());
49
				} else {
50
					throw new StartWriterVisitorException(getName(),e);
51
				}
40 52
			}
41 53
			/* Statement st = conn.createStatement();
42 54

  
......
177 189
		}
178 190
	}
179 191
}
192

  
193

  
194
// [eiel-gestion-conexiones]

Also available in: Unified diff