Revision 14244

View differences:

branches/v10/extensions/extSDE/src/com/iver/cit/gvsig/fmap/drivers/sde/ArcSdeDriver.java
43 43
 */
44 44
package com.iver.cit.gvsig.fmap.drivers.sde;
45 45

  
46
import java.awt.Component;
46 47
import java.awt.geom.Rectangle2D;
47 48
import java.io.IOException;
48 49
import java.sql.Types;
......
71 72
import com.hardcode.gdbms.engine.data.edition.DataWare;
72 73
import com.hardcode.gdbms.engine.values.Value;
73 74
import com.hardcode.gdbms.engine.values.ValueFactory;
75
import com.iver.andami.PluginServices;
74 76
import com.iver.andami.messages.Messages;
75 77
import com.iver.andami.messages.NotificationManager;
76 78
import com.iver.cit.gvsig.fmap.DriverException;
......
91 93
import com.iver.cit.gvsig.fmap.edition.IWriteable;
92 94
import com.iver.cit.gvsig.fmap.edition.IWriter;
93 95
import com.iver.cit.gvsig.fmap.layers.XMLException;
94
import com.iver.cit.gvsig.project.documents.gui.FOpenDialog;
95 96
import com.iver.utiles.XMLEntity;
96 97
import com.iver.utiles.swing.JPasswordDlg;
97 98

  
......
128 129
    protected String className;
129 130
    protected String catalogName;
130 131
	private ArcSdeWriter writer;
131
	private String userName;
132
	private String tableName;
132
//	private String userName;
133
//	private String tableName;
133 134
	private String FIDfield;
134 135
	private String geometryField;
135 136
	private String whereClause;
136 137
	private String strSRID;
137
	private String host;
138
	private String port;
139
	private String dbName;
140
	private String connName;
141
	private String dbUrl;
138
//	private String host;
139
//	private String port;
140
//	private String dbName;
141
//	private String connName;
142
//	private String dbUrl;
142 143
	private SeConnection alphanumericConnection;
143 144

  
144 145
    /**
......
506 507
                 for (int k = 1; k < fds.length+1; k++) {
507 508
                     fieldsAux[k] = fds[k - 1].getFieldName();
508 509
                 }
510
             }else{
511
            	 fieldsAux = new String[fds.length];
512
            	 for (int k = 0; k < fds.length; k++) {
513
                     fieldsAux[k] = fds[k].getFieldName();
514
                 }
509 515
             }
510 516
         }
511 517
        lyrDef.setFieldNames(fieldsAux);
......
516 522
        int instance = lyrDef.getPort();
517 523
        String database = lyrDef.getDataBase();
518 524
        String user = lyrDef.getUser();
519
        String password = lyrDef.getPassword();
525
//        String password = lyrDef.getPassword();
520 526
        String[] cols = lyrDef.getFieldNames();
521 527
        String tableName = lyrDef.getComposedTableName();
522

  
528
        String password;
529
        if (lyrDef.getPassword()!=null){
530
        	password=lyrDef.getPassword();
531
        }else{
532
        	String keyPool = getName().toLowerCase() + "_" + lyrDef.getHost().toLowerCase()
533
        		+ "_" + lyrDef.getPort() + "_" + lyrDef.getDataBase().toLowerCase()
534
        		+ "_" + lyrDef.getUser().toLowerCase();
535
        	password=(String)poolPassw.get(keyPool);
536
        }
523 537
        try {
524 538
            alphanumericConnection =new SeConnection(server, instance, database, user, password);
525 539
//            alphanumericConnection.startTransaction();
......
776 790
        xml.putProperty("driverclass", this.getClass().getName());
777 791
        xml.putProperty("catalog", lyrDef.getCatalogName());
778 792

  
793
        ConnectionWithParams cwp =
794
        	SingleVectorialDBConnectionManager.instance().findConnection(getConnection());
795

  
796

  
779 797
        // TODO: NO DEBEMOS GUARDAR EL NOMBRE DE USUARIO Y CONTRASE?A
780 798
        // AQUI. Hay que utilizar un pool de conexiones
781 799
        // y pedir al usuario que conecte a la base de datos
......
803 821
        xml.putProperty("host", lyrDef.getHost());
804 822
        xml.putProperty("port", lyrDef.getPort());
805 823
        xml.putProperty("dbName", lyrDef.getDataBase());
806
        xml.putProperty("connName", lyrDef.getConnectionName());
824
        xml.putProperty("connName", cwp.getName());
807 825

  
808 826
        xml.putProperty("typeShape",lyrDef.getShapeType());
809 827

  
......
956 974

  
957 975
                clave = (String) poolPassw.get(keyPool);
958 976
                cwp = SingleVectorialDBConnectionManager.instance().getConnection(
959
 					_drvName, userName, clave, connName,
960
 					host, port, dbName, true);
977
 					_drvName, lyrDef.getUser(), clave, lyrDef.getConnectionName(),
978
 					lyrDef.getHost(), String.valueOf(lyrDef.getPort()), lyrDef.getDataBase(), true);
961 979

  
962 980
            } else {
963 981

  
964 982
                cwp = SingleVectorialDBConnectionManager.instance().getConnection(
965
     					_drvName, userName, null, connName,
966
     					host, port, dbName, false);
983
     					_drvName, lyrDef.getUser(), null, lyrDef.getConnectionName(),
984
     					lyrDef.getHost(), String.valueOf(lyrDef.getPort()), lyrDef.getDataBase(), false);
967 985

  
968 986
                if (cwp.isConnected()) {
969 987

  
......
972 990
                } else {
973 991

  
974 992
                    JPasswordDlg dlg = new JPasswordDlg();
993
                    dlg.setLocationRelativeTo((Component)PluginServices.getMainFrame());
975 994
                    String strMessage = Messages.getString("conectar_jdbc");
976 995
                    String strPassword = Messages.getString("password");
977 996
                    dlg.setMessage(strMessage
978 997
                    		+ " ["
979 998
                    		+ _drvName + ", "
980
                    		+ host + ", "
981
                    		+ port + ", "
982
                    		+ dbName + ", "
983
                    		+ userName + "]. "
999
                    		+ lyrDef.getHost() + ", "
1000
                    		+ String.valueOf(lyrDef.getPort()) + ", "
1001
                    		+ lyrDef.getDataBase() + ", "
1002
                    		+ lyrDef.getUser() + "]. "
984 1003
                    		+ strPassword
985 1004
                    		+ "?");
986
                    dlg.show();
1005
                    dlg.setVisible(true);
987 1006
                    clave = dlg.getPassword();
988 1007
                    if (clave == null)
989 1008
                        return;

Also available in: Unified diff