Package com.GestDB.sql

Source Code of com.GestDB.sql.SelectConexion

/*
* SelectConexion.java
*
* Created on 2004
* Created by Arsenio Molinero
* Copyright (C) 2004, 2005 Arsenio Molinero
*
* GestDB - a Java multi database client
*
* This file is part of GestDB.
*
* GestDB is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GestDB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GestDB; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

package com.GestDB.sql;

import com.GestDB.general.Trackbug;
import com.GestDB.*;
import com.GestDB.swing.*;
import java.awt.*;
import java.util.Vector;
import java.util.Properties;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
import javax.swing.*;
import com.GestDB.swing.tmodelTabla;
// import com.sun.org.apache.bcel.internal.generic.SALOAD;
import java.sql.Connection;
import java.sql.DriverManager;

/**
*
* @author  amolinero
*/
public class SelectConexion extends javax.swing.JDialog implements Literales {
   
    /** Creates new form SelectConexion */
    public SelectConexion(java.awt.Frame parent, boolean modal) {
        super(parent, modal);

        tm = new tmodelTabla();
       
        initComponents();

        PonLiterales();

       
        jtConexiones.setModel(tm);
        stm1 = new SortTModel(jtConexiones,tm);
        stm1.addMouseListenerToHeaderInTable(jtConexiones);
        stm1.addSortListener(this);
        jcGestor.setModel(new javax.swing.DefaultComboBoxModel(CONEXIONES));
        jcGestor2.setModel(new javax.swing.DefaultComboBoxModel(CONEXIONES));
        jcbGestores.setModel(new javax.swing.DefaultComboBoxModel(CONEXIONES));
        jcbGestores.insertItemAt("",0);
        jcbGestores.setSelectedIndex(0);
        grupoActual = "";
        CargaConexiones();
        RellenaComboGrupos();

        String grupo = Gestor.GetLiteral("selectconexion.all_connection","Todas las conexiones");
        if(Gestor.propiedades.containsKey("SelectConexion.grupoSeleccionado"))
            grupo = (String)Gestor.propiedades.get("SelectConexion.grupoSeleccionado");

        RellenaConexiones(grupo);
       
        grupoActual = grupo;
        cbGrupos.setSelectedItem(grupo);

        showProperties(jcbGestores.getModel().getElementAt(0).toString());

        if(Gestor.propiedades.containsKey("selectconexion.table_columns_width"))
        {
            String anchos[] = ((String)Gestor.propiedades.get("selectconexion.table_columns_width")).split("-");
            for(int i=0; i < anchos.length; i++)
            {
                try {
                    jtConexiones.getTableHeader().getColumnModel().getColumn(i).setPreferredWidth(Integer.parseInt(anchos[i]));
                }catch(Exception e)
                {
                    ;
                }
            }
        }

        /*
        GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
        Rectangle TamanioMax = ge.getMaximumWindowBounds();
        Point pCentro = ge.getCenterPoint();
        setLocation((int)(pCentro.getX() - (this.getWidth()/2)),
        (int)(pCentro.getY() - (this.getHeight()/2)));
         */
    }

    public void ChangeSort()
    {
        // actualizamos los tama�os de las columnas
        if(Gestor.propiedades.containsKey("selectconexion.table_columns_width"))
        {
            String anchos[] = ((String)Gestor.propiedades.get("selectconexion.table_columns_width")).split("-");
            for(int i=0; i < anchos.length; i++)
            {
                try {
                    jtConexiones.getTableHeader().getColumnModel().getColumn(i).setPreferredWidth(Integer.parseInt(anchos[i]));
                }catch(Exception e)
                {
                    ;
                }
            }
        }
    }

    private void RellenaConexiones(String grupo)
    {
        Vector rows = new Vector();
       
        String sNombreConexion = jtfNombreFiltro.getText().trim().toLowerCase();
        boolean comprobarNombre = (sNombreConexion.length() > 0);
        String sGestorConexion = jcbGestores.getSelectedItem().toString().trim().toLowerCase();
        boolean comprobarGestor = (sGestorConexion.length() > 0);
        String stemp = null;
        Vector cols = null;

        if(grupo.length() == 0 || grupo.equals(Gestor.GetLiteral("selectconexion.all_connection","Todas las conexiones"))) // muestra todas las conexiones
        {
            for (Enumeration e = vConexiones.elements() ; e.hasMoreElements() ;) {
                stemp = (String)e.nextElement();
                if(!comprobarNombre || (comprobarNombre && stemp.trim().toLowerCase().indexOf(sNombreConexion) != -1))
                {
                    cols = ComponeRow(stemp);
                    if(!comprobarGestor || (comprobarGestor && cols.elementAt(1).toString().trim().toLowerCase().equals(sGestorConexion)))
                        rows.addElement(cols);
                }
            }
        }
        else // muestra las conexiones del grupo
        {
            String conexiones = "";
            if(hmGrupos.get(grupo) != null)
                conexiones = hmGrupos.get(grupo).toString();
            if(conexiones == null)
                conexiones = "";
           
            StringTokenizer st1 = new StringTokenizer(conexiones,";",false);
            while(st1.hasMoreTokens())
            {
                stemp = st1.nextToken();
                if(!comprobarNombre || (comprobarNombre && stemp.trim().toLowerCase().indexOf(sNombreConexion) != -1))
                {
                    cols = ComponeRow(stemp);
                    if(!comprobarGestor || (comprobarGestor && cols.elementAt(1).toString().trim().toLowerCase().equals(sGestorConexion)))
                        rows.addElement(cols);
                }
            }
        }
       
        tm.CargaDatos(titulos,clases,true,rows);
        // actualizamos los tama�os de las columnas
        if(Gestor.propiedades.containsKey("selectconexion.table_columns_width"))
        {
            String anchos[] = ((String)Gestor.propiedades.get("selectconexion.table_columns_width")).split("-");
            for(int i=0; i < anchos.length; i++)
            {
                try {
                    jtConexiones.getTableHeader().getColumnModel().getColumn(i).setPreferredWidth(Integer.parseInt(anchos[i]));
                }catch(Exception e)
                {
                    ;
                }
            }
        }
    }
   
    private Vector ComponeRow(String stemp)
    {
        HashMap hm = getHMConexion(stemp,Propiedades);
        Vector cols = new Vector(hm.size());
        cols.addElement(stemp);
        if(hm.containsKey("gestor"))
            cols.addElement(hm.get("gestor"));
        else
            cols.addElement("");

        if(hm.containsKey("sid"))
            cols.addElement(hm.get("sid"));
        else
            cols.addElement("");

        if(hm.containsKey("user"))
            cols.addElement(hm.get("user"));
        else
            cols.addElement("");

        if(hm.containsKey("ip"))
            cols.addElement(hm.get("ip"));
        else
            cols.addElement("");

        if(hm.containsKey("puerto"))
            cols.addElement(hm.get("puerto"));
        else
            cols.addElement("");

        return cols;
    }
   
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jpCardLayout = new javax.swing.JPanel();
        jpConexiones = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jtConexiones = new javax.swing.JTable();
        jpFiltros = new javax.swing.JPanel();
        jpFiltrosTipo = new javax.swing.JPanel();
        jlGestor = new javax.swing.JLabel();
        jcbGestores = new javax.swing.JComboBox();
        jpGrupos = new javax.swing.JPanel();
        jlGrupo = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        cbGrupos = new javax.swing.JComboBox();
        jPanel8 = new javax.swing.JPanel();
        addGrupo = new javax.swing.JButton();
        mdfGrupo = new javax.swing.JButton();
        delGrupo = new javax.swing.JButton();
        jpNombre = new javax.swing.JPanel();
        jlNombre = new javax.swing.JLabel();
        jtfNombreFiltro = new javax.swing.JTextField();
        jPanel10 = new javax.swing.JPanel();
        jbCrear = new javax.swing.JButton();
        jbModificar = new javax.swing.JButton();
        jbCopiar = new javax.swing.JButton();
        jbBorrar = new javax.swing.JButton();
        jbConectar = new javax.swing.JButton();
        jpCrear = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jtNombre = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jtSID = new javax.swing.JTextField();
        lSID = new javax.swing.JLabel();
        jtIP = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jtPuerto = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jcGestor = new javax.swing.JComboBox();
        jtUsuario = new javax.swing.JTextField();
        jButton3 = new javax.swing.JButton();
        jbVerPassword = new javax.swing.JButton();
        jLabel91 = new javax.swing.JLabel();
        jtInfomixServer = new javax.swing.JTextField();
        jbCancelarCrear = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        jPasswordField1 = new javax.swing.JPasswordField();
        jbProbarConex = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jpModificar = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jtNombre2 = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jcGestor2 = new javax.swing.JComboBox();
        lSID2 = new javax.swing.JLabel();
        jtSID2 = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jtIP2 = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        jtPuerto2 = new javax.swing.JTextField();
        jLabel14 = new javax.swing.JLabel();
        jtUsuario2 = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jtInfomixServer2 = new javax.swing.JTextField();
        jLabel912 = new javax.swing.JLabel();
        jlTitleModificar = new javax.swing.JLabel();
        jbCancelarModificar = new javax.swing.JButton();
        jPasswordField2 = new javax.swing.JPasswordField();
        jbProbarConex2 = new javax.swing.JButton();
        jbVerPassword2 = new javax.swing.JButton();
        jpBorrar = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jlConexion = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();

        setTitle("Conexiones. Seleccione una conexi�n");
        setBackground(new java.awt.Color(204, 204, 204));
        setModal(true);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                closeDialog(evt);
            }
        });
        getContentPane().setLayout(new java.awt.GridLayout(1, 1));

        jpCardLayout.setLayout(new java.awt.CardLayout());

        jpConexiones.setLayout(new java.awt.BorderLayout());

        jtConexiones.setModel(tm);
        jtConexiones.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jtConexionesMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(jtConexiones);

        jpConexiones.add(jScrollPane2, java.awt.BorderLayout.CENTER);

        jpFiltros.setLayout(new java.awt.GridLayout(3, 0));

        jpFiltrosTipo.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        jlGestor.setText("Gestor:");
        jpFiltrosTipo.add(jlGestor);

        jcbGestores.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jcbGestores.setPreferredSize(new java.awt.Dimension(255, 19));
        jcbGestores.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                jcbGestoresItemStateChanged(evt);
            }
        });
        jpFiltrosTipo.add(jcbGestores);

        jpFiltros.add(jpFiltrosTipo);

        jpGrupos.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        jlGrupo.setText("Grupo:");
        jpGrupos.add(jlGrupo);

        jPanel7.setLayout(new java.awt.BorderLayout());

        cbGrupos.setPreferredSize(new java.awt.Dimension(300, 19));
        cbGrupos.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbGruposItemStateChanged(evt);
            }
        });
        jPanel7.add(cbGrupos, java.awt.BorderLayout.CENTER);

        jPanel8.setLayout(new java.awt.GridLayout(1, 0));

        addGrupo.setText("+");
        addGrupo.setMargin(new java.awt.Insets(2, 2, 2, 2));
        addGrupo.setPreferredSize(new java.awt.Dimension(26, 21));
        addGrupo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addGrupoActionPerformed(evt);
            }
        });
        jPanel8.add(addGrupo);

        mdfGrupo.setText("M");
        mdfGrupo.setMargin(new java.awt.Insets(2, 2, 2, 2));
        mdfGrupo.setPreferredSize(new java.awt.Dimension(26, 21));
        mdfGrupo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mdfGrupoActionPerformed(evt);
            }
        });
        jPanel8.add(mdfGrupo);

        delGrupo.setText("-");
        delGrupo.setMargin(new java.awt.Insets(2, 2, 2, 2));
        delGrupo.setPreferredSize(new java.awt.Dimension(26, 21));
        delGrupo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                delGrupoActionPerformed(evt);
            }
        });
        jPanel8.add(delGrupo);

        jPanel7.add(jPanel8, java.awt.BorderLayout.EAST);

        jpGrupos.add(jPanel7);

        jpFiltros.add(jpGrupos);

        jpNombre.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));

        jlNombre.setText("Nombre:");
        jpNombre.add(jlNombre);

        jtfNombreFiltro.setPreferredSize(new java.awt.Dimension(250, 19));
        jtfNombreFiltro.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                jtfNombreFiltroKeyReleased(evt);
            }
        });
        jpNombre.add(jtfNombreFiltro);

        jpFiltros.add(jpNombre);

        jpConexiones.add(jpFiltros, java.awt.BorderLayout.NORTH);

        jbCrear.setText("Crear");
        jbCrear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCrearActionPerformed(evt);
            }
        });
        jPanel10.add(jbCrear);

        jbModificar.setText("Modificar");
        jbModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbModificarActionPerformed(evt);
            }
        });
        jPanel10.add(jbModificar);

        jbCopiar.setText("Copiar");
        jbCopiar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCopiarActionPerformed(evt);
            }
        });
        jPanel10.add(jbCopiar);

        jbBorrar.setText("Borrar");
        jbBorrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbBorrarActionPerformed(evt);
            }
        });
        jPanel10.add(jbBorrar);

        jbConectar.setText("Conectar");
        jbConectar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbConectarActionPerformed(evt);
            }
        });
        jPanel10.add(jbConectar);

        jpConexiones.add(jPanel10, java.awt.BorderLayout.SOUTH);

        jpCardLayout.add(jpConexiones, "conexiones");

        jpCrear.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel3.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel3.setText("Nombre: ");
        jpCrear.add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 30, 92, -1));

        jtNombre.setFont(new java.awt.Font("Verdana", 0, 12));
        jpCrear.add(jtNombre, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 30, 160, -1));

        jLabel4.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel4.setText("Gestor BBDD: ");
        jpCrear.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 50, 92, -1));

        jtSID.setFont(new java.awt.Font("Verdana", 0, 12));
        jpCrear.add(jtSID, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 70, 160, -1));

        lSID.setFont(new java.awt.Font("Verdana", 0, 12));
        lSID.setText("SID: ");
        jpCrear.add(lSID, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 70, 92, -1));

        jtIP.setFont(new java.awt.Font("Verdana", 0, 12));
        jpCrear.add(jtIP, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 90, 160, -1));

        jLabel6.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel6.setText("IP: ");
        jpCrear.add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 90, 92, -1));

        jtPuerto.setFont(new java.awt.Font("Verdana", 0, 12));
        jpCrear.add(jtPuerto, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 110, 140, -1));

        jLabel7.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel7.setText("Puerto: ");
        jpCrear.add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 110, 92, -1));

        jLabel8.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel8.setText("Usuario: ");
        jpCrear.add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 130, 92, -1));

        jLabel9.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel9.setText("Contrase�a: ");
        jpCrear.add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 150, 92, -1));

        jcGestor.setFont(new java.awt.Font("Verdana", 0, 12));
        jcGestor.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcGestorActionPerformed(evt);
            }
        });
        jpCrear.add(jcGestor, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 50, 160, 20));

        jtUsuario.setFont(new java.awt.Font("Verdana", 0, 12));
        jpCrear.add(jtUsuario, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 130, 160, -1));

        jButton3.setFont(new java.awt.Font("Verdana", 0, 12)); // NOI18N
        jButton3.setText("Crear Conexi�n");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jpCrear.add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 210, -1, -1));

        jbVerPassword.setText("*");
        jbVerPassword.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbVerPasswordActionPerformed(evt);
            }
        });
        jpCrear.add(jbVerPassword, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 150, 20, 20));

        jLabel91.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel91.setText("Servidor Informix:");
        jpCrear.add(jLabel91, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 170, 120, -1));

        jtInfomixServer.setFont(new java.awt.Font("Verdana", 0, 12));
        jpCrear.add(jtInfomixServer, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 170, 160, -1));

        jbCancelarCrear.setFont(new java.awt.Font("Verdana", 0, 12)); // NOI18N
        jbCancelarCrear.setText("Cancelar");
        jbCancelarCrear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCancelarCrearActionPerformed(evt);
            }
        });
        jpCrear.add(jbCancelarCrear, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 210, -1, -1));

        jLabel11.setFont(new java.awt.Font("Verdana", 1, 14));
        jLabel11.setText("Crear conexi�n");
        jpCrear.add(jLabel11, new org.netbeans.lib.awtextra.AbsoluteConstraints(230, 0, -1, -1));
        jpCrear.add(jPasswordField1, new org.netbeans.lib.awtextra.AbsoluteConstraints(270, 150, 140, -1));

        jbProbarConex.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
        jbProbarConex.setText("Probar conexi�n");
        jbProbarConex.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbProbarConexActionPerformed(evt);
            }
        });
        jpCrear.add(jbProbarConex, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 210, -1, -1));

        jButton7.setText("*");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });
        jpCrear.add(jButton7, new org.netbeans.lib.awtextra.AbsoluteConstraints(410, 110, 20, 20));

        jpCardLayout.add(jpCrear, "crear");

        jpModificar.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel5.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel5.setText("Nombre:");
        jpModificar.add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 40, 70, -1));

        jtNombre2.setEditable(false);
        jtNombre2.setFont(new java.awt.Font("Verdana", 0, 12));
        jpModificar.add(jtNombre2, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 40, 160, -1));

        jLabel10.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel10.setText("Gestor BBDD:");
        jpModificar.add(jLabel10, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 60, -1, -1));

        jcGestor2.setFont(new java.awt.Font("Verdana", 0, 12));
        jcGestor2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jcGestor2ActionPerformed(evt);
            }
        });
        jpModificar.add(jcGestor2, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 60, 160, 20));

        lSID2.setFont(new java.awt.Font("Verdana", 0, 12));
        lSID2.setText("SID:");
        jpModificar.add(lSID2, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 80, 70, -1));

        jtSID2.setFont(new java.awt.Font("Verdana", 0, 12));
        jpModificar.add(jtSID2, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 80, 160, -1));

        jLabel12.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel12.setText("IP:");
        jpModificar.add(jLabel12, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 100, 90, -1));

        jtIP2.setFont(new java.awt.Font("Verdana", 0, 12));
        jpModificar.add(jtIP2, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 100, 160, -1));

        jLabel13.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel13.setText("Puerto:");
        jpModificar.add(jLabel13, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 120, 70, -1));

        jtPuerto2.setFont(new java.awt.Font("Verdana", 0, 12));
        jpModificar.add(jtPuerto2, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 120, 140, -1));

        jLabel14.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel14.setText("Usuario:");
        jpModificar.add(jLabel14, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 140, 70, -1));

        jtUsuario2.setFont(new java.awt.Font("Verdana", 0, 12));
        jpModificar.add(jtUsuario2, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 140, 160, -1));

        jLabel15.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel15.setText("Contrase�a:");
        jpModificar.add(jLabel15, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 160, -1, -1));

        jButton4.setFont(new java.awt.Font("Verdana", 0, 12)); // NOI18N
        jButton4.setText("Aceptar cambios");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jpModificar.add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 210, -1, -1));

        jButton6.setText("*");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        jpModificar.add(jButton6, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 120, 20, 20));

        jtInfomixServer2.setFont(new java.awt.Font("Verdana", 0, 12));
        jpModificar.add(jtInfomixServer2, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 180, 160, -1));

        jLabel912.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel912.setText("Servidor Informix:");
        jpModificar.add(jLabel912, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 180, 120, -1));

        jlTitleModificar.setFont(new java.awt.Font("Verdana", 1, 14));
        jlTitleModificar.setText("Modificar conexi�n");
        jpModificar.add(jlTitleModificar, new org.netbeans.lib.awtextra.AbsoluteConstraints(220, 0, -1, -1));

        jbCancelarModificar.setFont(new java.awt.Font("Verdana", 0, 12)); // NOI18N
        jbCancelarModificar.setText("Cancelar");
        jbCancelarModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCancelarModificarActionPerformed(evt);
            }
        });
        jpModificar.add(jbCancelarModificar, new org.netbeans.lib.awtextra.AbsoluteConstraints(420, 210, -1, -1));
        jpModificar.add(jPasswordField2, new org.netbeans.lib.awtextra.AbsoluteConstraints(260, 160, 140, -1));

        jbProbarConex2.setFont(new java.awt.Font("Dialog", 0, 12)); // NOI18N
        jbProbarConex2.setText("Probar conexi�n");
        jbProbarConex2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbProbarConex2ActionPerformed(evt);
            }
        });
        jpModificar.add(jbProbarConex2, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 210, -1, -1));

        jbVerPassword2.setText("*");
        jbVerPassword2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbVerPassword2ActionPerformed(evt);
            }
        });
        jpModificar.add(jbVerPassword2, new org.netbeans.lib.awtextra.AbsoluteConstraints(400, 160, 20, 20));

        jpCardLayout.add(jpModificar, "modificar");

        jpBorrar.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jLabel1.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("�Esta seguro que desea borrar la conexi�n?");
        jpBorrar.add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 90, 590, -1));

        jlConexion.setFont(new java.awt.Font("Verdana", 0, 12));
        jlConexion.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jlConexion.setText("Conexi�n");
        jpBorrar.add(jlConexion, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 60, 590, -1));

        jButton1.setFont(new java.awt.Font("Verdana", 0, 12));
        jButton1.setText("Si");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jPanel5.add(jButton1);

        jButton2.setFont(new java.awt.Font("Verdana", 0, 12));
        jButton2.setText("No");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel5.add(jButton2);

        jpBorrar.add(jPanel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 120, 590, 40));

        jpCardLayout.add(jpBorrar, "borrar");

        getContentPane().add(jpCardLayout);

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-593)/2, (screenSize.height-518)/2, 593, 518);
    }// </editor-fold>//GEN-END:initComponents

    private void jcbGestoresItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jcbGestoresItemStateChanged
        RellenaConexiones(grupoActual);
    }//GEN-LAST:event_jcbGestoresItemStateChanged

    private void jtfNombreFiltroKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jtfNombreFiltroKeyReleased
        RellenaConexiones(grupoActual);
    }//GEN-LAST:event_jtfNombreFiltroKeyReleased

    private void jbCancelarModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCancelarModificarActionPerformed
            ((CardLayout)jpCardLayout.getLayout()).first(jpCardLayout);
    }//GEN-LAST:event_jbCancelarModificarActionPerformed

    private void jbCancelarCrearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCancelarCrearActionPerformed
            ((CardLayout)jpCardLayout.getLayout()).first(jpCardLayout);
    }//GEN-LAST:event_jbCancelarCrearActionPerformed

    private void jtConexionesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtConexionesMouseClicked
        // nos aseguramos que sea doble click, de serlo abrimos la conexi�n
        long mili = new java.util.Date().getTime();
        if( (mili - milisegundos) < 1000 ) // doble click
        {
            sKey = (String)stm1.getValueAt(jtConexiones.getSelectedRow(),0);
            jlConexion.setText(Gestor.GetLiteral("selectconexion.connection","Conexi�n") + ": " + sKey);
            setTitle(Gestor.GetLiteral("selectconexion.connection","Conexi�n") + ": " + sKey);
            abrirConexion();
        }
        else milisegundos = mili;
    }//GEN-LAST:event_jtConexionesMouseClicked

    private void jbBorrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbBorrarActionPerformed
        if(jtConexiones.getSelectedRow() != -1) {
            sKey = (String)stm1.getValueAt(jtConexiones.getSelectedRow(),0);
            jlConexion.setText(Gestor.GetLiteral("selectconexion.connection","Conexi�n") + ": " + sKey);
            setTitle(Gestor.GetLiteral("selectconexion.connection","Conexi�n") + ": " + sKey);

            // pone visible la lengueta de borrar
            ((java.awt.CardLayout)this.jpCardLayout.getLayout()).show(jpCardLayout,"borrar");
        }
    }//GEN-LAST:event_jbBorrarActionPerformed

    private void jbCrearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCrearActionPerformed
        // limpia los datos anteriores de la lengueta de crear.
        jtNombre.setText("");
        jtIP.setText("");
        jtSID.setText("");
        jtPuerto.setText("");
        jtInfomixServer.setText("");
        jtUsuario.setText("");
        jPasswordField1.setText("");
        // pone visible la lengueta de crear
        ((java.awt.CardLayout)this.jpCardLayout.getLayout()).show(jpCardLayout,"crear");
    }//GEN-LAST:event_jbCrearActionPerformed

    private void jbConectarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbConectarActionPerformed
        if(jtConexiones.getSelectedRow() != -1) {
            sKey = (String)stm1.getValueAt(jtConexiones.getSelectedRow(),0);
            jlConexion.setText(Gestor.GetLiteral("selectconexion.connection","Conexi�n") + ": " + sKey);
            setTitle(Gestor.GetLiteral("selectconexion.connection","Conexi�n") + ": " + sKey);
            abrirConexion();
        }
    }//GEN-LAST:event_jbConectarActionPerformed

    private void jbModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbModificarActionPerformed
        // Modificar Conexi�n
        if(jtConexiones.getSelectedRow() != -1) {
            sKey = (String)stm1.getValueAt(jtConexiones.getSelectedRow(),0);
            jlConexion.setText(Gestor.GetLiteral("selectconexion.connection","Conexi�n") + ": " + sKey);
            setTitle(Gestor.GetLiteral("selectconexion.connection","Conexi�n") + ": " + sKey);
            // pone la key en el nombre
            jtNombre2.setText(sKey);
           
            RellenaCamposConexion(jcGestor2, jtIP2, jtSID2, jtPuerto2, jtInfomixServer2, jtUsuario2, jPasswordField2);
            // pone visible la lengueta de modificar
            ((java.awt.CardLayout)this.jpCardLayout.getLayout()).show(jpCardLayout,"modificar");
        }
    }//GEN-LAST:event_jbModificarActionPerformed

    private void jbCopiarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCopiarActionPerformed
        // Se ha pulsado en copiar conexi�n, nos aseguramos que tiene seleccionada alguna
        if(jtConexiones.getSelectedRow() != -1) {
            sKey = (String)stm1.getValueAt(jtConexiones.getSelectedRow(),0);
            jlConexion.setText(Gestor.GetLiteral("selectconexion.connection","Conexi�n") + ": " + sKey);
            setTitle(Gestor.GetLiteral("selectconexion.connection","Conexi�n") + ": " + sKey);
            RellenaCamposConexion(jcGestor, jtIP, jtSID, jtPuerto, jtInfomixServer, jtUsuario, jPasswordField1);
            // pone visible la lengueta de nueva
            ((java.awt.CardLayout)this.jpCardLayout.getLayout()).show(jpCardLayout,"crear");
        }
       
    }//GEN-LAST:event_jbCopiarActionPerformed

    private void cbGruposItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbGruposItemStateChanged
        // Muestra las conexiones del grupo seleccionado.
        Vector rows = new Vector();
        String grupo = cbGrupos.getSelectedItem().toString();
        if(grupoActual.equals(""))
            return;

        RellenaConexiones(grupo);
       
        grupoActual = grupo;
        // guarda el �ltimo grupo seleccionado para que carge el mismo cuando entre la siguiente vez
        Gestor.propiedades.put("SelectConexion.grupoSeleccionado", grupo);               
    }//GEN-LAST:event_cbGruposItemStateChanged

    private void delGrupoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_delGrupoActionPerformed
        // elimina el grupo
        String grupo = cbGrupos.getSelectedItem().toString();
        if(!grupo.equals(Gestor.GetLiteral("selectconexion.all_connection","Todas las conexiones")))
        {
            Alerta al = new Alerta(this, Gestor.GetLiteral("gestor.alert","Atenci�n"), true,
                Gestor.GetLiteral("selectconexion.question_2","Desea eliminar el grupo") + " " + grupo, Alerta.OKCANCEL);
            al.setVisible(true);
            if(al.getReturnStatus() == al.RET_OK)
            {
                hmGrupos.remove(grupo);
                for(int i=0,j=cbGrupos.getModel().getSize();i<j;i++)
                {
                    if(((String)cbGrupos.getModel().getElementAt(i)).equals(grupo))
                    {
                        ((DefaultComboBoxModel)cbGrupos.getModel()).removeElementAt(i);
                        break;
                    }
                }

                cbGrupos.setSelectedIndex(0);
                Gestor.propiedades.remove("SelectConexion.grupo." + grupo);
            }
        }
    }//GEN-LAST:event_delGrupoActionPerformed

    private void mdfGrupoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mdfGrupoActionPerformed
        // permite modificar el grupo
        String grupo = cbGrupos.getSelectedItem().toString();
        if(!grupo.equals(Gestor.GetLiteral("selectconexion.all_connection","Todas las conexiones")))
        {
            String conexiones = hmGrupos.get(grupo).toString();
            if(conexiones == null)
                conexiones = "";
            dlgMdfGrupos gr = new dlgMdfGrupos((Frame)this.getParent(),true,vConexiones, grupo,conexiones);
            gr.setVisible(true);
            if(gr.bCancelada == false)
            {
                hmGrupos.remove(grupo);
                hmGrupos.put(gr.getNombre(), gr.getConexiones());
                ((DefaultComboBoxModel)cbGrupos.getModel()).removeElement(grupo);               
/*
                for(int i=0,j=cbGrupos.getModel().getSize();i<j;i++)
                {
                    if(((String)cbGrupos.getModel().getElementAt(i)).equals(grupo))
                    {
                        cbGrupos.remove(i);
                        break;
                    }
                }
*/
                cbGrupos.addItem(gr.getNombre());
                Gestor.propiedades.remove("SelectConexion.grupo." + grupo);
                Gestor.propiedades.put("SelectConexion.grupo." + gr.getNombre(), gr.getConexiones());
            }       
        }
    }//GEN-LAST:event_mdfGrupoActionPerformed

    private void addGrupoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addGrupoActionPerformed
        // permite crear un grupo
        dlgMdfGrupos gr = new dlgMdfGrupos((Frame)this.getParent(),true,vConexiones, "","");
        gr.setVisible(true);
        if(gr.bCancelada == false)
        {
                hmGrupos.put(gr.getNombre(), gr.getConexiones());
                cbGrupos.addItem(gr.getNombre());
                Gestor.propiedades.put("SelectConexion.grupo." + gr.getNombre(), gr.getConexiones());
        }       
    }//GEN-LAST:event_addGrupoActionPerformed
   

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        String opcion = (String)jcGestor2.getSelectedItem();
        if(hmPUERTOS.containsKey(opcion))
            jtPuerto2.setText((String)hmPUERTOS.get(opcion));
       
    }//GEN-LAST:event_jButton6ActionPerformed
   
    private void jbVerPasswordActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbVerPasswordActionPerformed
        Alerta al = new Alerta(this, Gestor.GetLiteral("selectconexion.password","Contraseña"), true,
            (evt.getSource().equals(jbVerPassword))?new String(jPasswordField1.getPassword()):new String(jPasswordField2.getPassword()),
            Alerta.OK);
        al.setVisible(true);
        al = null;
       
    }//GEN-LAST:event_jbVerPasswordActionPerformed
   
    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        CompruebaCampos(jtNombre2, jcGestor2, jtIP2, jtSID2, jtPuerto2, jtInfomixServer2, jtUsuario2, jPasswordField2, true);
    }//GEN-LAST:event_jButton4ActionPerformed
   
    private void jcGestor2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcGestor2ActionPerformed
        showProperties((String)jcGestor2.getSelectedItem());

    }//GEN-LAST:event_jcGestor2ActionPerformed
   
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        CompruebaCampos(jtNombre, jcGestor, jtIP, jtSID, jtPuerto, jtInfomixServer, jtUsuario, jPasswordField1, true);
    }//GEN-LAST:event_jButton3ActionPerformed
   
    private void jcGestorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jcGestorActionPerformed
        showProperties((String)jcGestor.getSelectedItem());

    }//GEN-LAST:event_jcGestorActionPerformed
   
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        if(sKey != null && sKey.length() > 0) {
            Propiedades.remove(sKey);
            sKey = "";
           
            Gestor.GuardaConexiones(this.getClass(), Propiedades);
            CargaConexiones();
            setTitle(Gestor.GetLiteral("selectconexion.select_conection","Conexiones. Seleccione una conexi�n"));
            ((CardLayout)jpCardLayout.getLayout()).first(jpCardLayout);
        }
    }//GEN-LAST:event_jButton1ActionPerformed
   
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        ((CardLayout)jpCardLayout.getLayout()).first(jpCardLayout);
    }//GEN-LAST:event_jButton2ActionPerformed
           
    /** Closes the dialog */
    private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog
        bCancelado = true;
        setAbrir(false);
        setVisible(false);
       
        String sAnchos = "";
        String anchos[] = new String[jtConexiones.getTableHeader().getColumnModel().getColumnCount()];
        for(int i=0; i < anchos.length; i++)
        {
            if(i > 0)
                sAnchos += "-";
            sAnchos += String.valueOf(jtConexiones.getTableHeader().getColumnModel().getColumn(i).getPreferredWidth());
        }
       
        Gestor.propiedades.setProperty("selectconexion.table_columns_width",sAnchos);

        dispose();
    }//GEN-LAST:event_closeDialog

    private void jbProbarConexActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbProbarConexActionPerformed
        boolean resultado = false;
        if(evt.getSource().equals(jbProbarConex))
            resultado = CompruebaCampos(jtNombre, jcGestor, jtIP, jtSID, jtPuerto, jtInfomixServer, jtUsuario, jPasswordField1 , false);
        else
            resultado = CompruebaCampos(jtNombre2, jcGestor2, jtIP2, jtSID2, jtPuerto2, jtInfomixServer2, jtUsuario2, jPasswordField2 , false);
       
        if(resultado)
        {
            // jdbcDriverClass, jdbcDriverURL, user, y password tenemos los datos para conectarnos

            // si el usuario esta vacio se pide
            if(user == null || user.trim().length() == 0)
            {
                EnterSingleData edata = new EnterSingleData(new JFrame(),true,
                        Gestor.GetLiteral("selectconexion.enter_user","Introduzca el usuario"),
                        Gestor.GetLiteral("selectconexion.user","Usuario"));
                edata.setVisible(true);
                if(edata.getReturnStatus() == edata.RET_OK)
                    user = edata.jTextField1.getText();
            }

            // si el password esta vacio se pide
            if(password == null || password.trim().length() == 0)
            {
                EnterSingleData edata = new EnterSingleData(new JFrame(),true,
                        Gestor.GetLiteral("selectconexion.enter_password","Introduzca la contrase�a"),
                        Gestor.GetLiteral("selectconexion.password","Contrase�a"));
                edata.setVisible(true);
                if(edata.getReturnStatus() == edata.RET_OK)
                    password = edata.jTextField1.getText();
            }

            // carga la clase
            try {
                Class.forName(jdbcDriverClass);
            } catch(java.lang.ClassNotFoundException nfe) {
                // tenemos que sacar una ventana indicando que nos falta el driver jdbc y que tenemos que copiarlo al directorio
                // lib y rearancar el programa
                Alerta al = new Alerta(this, Gestor.GetLiteral("gestor.error_1","Error"), true,
                    Gestor.GetLiteral("conexiontxt.error_2","No se encuentran las clases correspondientes al driver jdbc de la base de datos.") +
                    "\n" + Gestor.GetLiteral("selectconexion.getdriver","Descargueselo de la web del fabricante de la BBDD o busquelo en 'http://developers.sun.com/product/jdbc/drivers'.") +
                    "\n" + Gestor.GetLiteral("selectconexion.copydriver","Cuando tenga el archivo JAR o ZIP c�pielo al directorio 'lib' del GestDB y rearranque el programa."), Alerta.OK);
                al.setVisible(true);
                al = null;
                return;
            }

            // vamos con la conexi�n
            Connection connection = null;

            String jdbcDriverURL2 = jdbcDriverURL;
            if(jdbcDriverURL.startsWith("custom:"))
            {
                int posi = jdbcDriverURL.indexOf("???");
                if(posi != -1)
                    jdbcDriverURL2 = jdbcDriverURL.substring(posi + 3);
                else
                    jdbcDriverURL2 = jdbcDriverURL.substring(7);
            }

            try {
                if(user != null && user.trim().length() != 0)
                    connection = DriverManager.getConnection(jdbcDriverURL2, user, password);
                else
                    connection = DriverManager.getConnection(jdbcDriverURL2);

                if(connection != null)
                    connection.close();

                Alerta al = new Alerta(this, Gestor.GetLiteral("gestor.alert","Atenci�n"), true,
                        Gestor.GetLiteral("selectconexion.conection_ok","Conexi�n OK"), Alerta.OK);
                al.setVisible(true);
                al = null;
                return;

            } catch (Exception ex) {
                Alerta al = new Alerta(this, Gestor.GetLiteral("gestor.error_1","Error"), true, ex.getMessage(), Alerta.OK);
                al.setVisible(true);
                al = null;
                return;
            }
           
        }
    }//GEN-LAST:event_jbProbarConexActionPerformed

    private void jbProbarConex2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbProbarConex2ActionPerformed
        jbProbarConexActionPerformed(evt);
    }//GEN-LAST:event_jbProbarConex2ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        String opcion = (String)jcGestor.getSelectedItem();
        if(hmPUERTOS.containsKey(opcion))
            jtPuerto.setText((String)hmPUERTOS.get(opcion));

    }//GEN-LAST:event_jButton7ActionPerformed

    private void jbVerPassword2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbVerPassword2ActionPerformed
        jbVerPasswordActionPerformed(evt);
    }//GEN-LAST:event_jbVerPassword2ActionPerformed

    private void showProperties(String TypeManager)
    {
        boolean bEsCustom = TypeManager.equals(CUSTOM);
        boolean bShowSID = vOnlyHostPort.contains(TypeManager) == false;
        boolean bShowIPPort = vOnlyDBName.contains(TypeManager) == false;
        boolean bEsInformix = TypeManager.equals(INFORMIX);
        Trackbug.info("TypeManager: " + TypeManager + ", bEsCustom: " + bEsCustom + ", bShowSID: " + bShowSID + ", bShowIPPort:" + bShowIPPort + ", bEsInformix: " + bEsInformix);
        if(hmSID.containsKey(TypeManager))
        {
            lSID.setText((String)hmSID.get(TypeManager));
            lSID2.setText((String)hmSID.get(TypeManager));
        }

        if(bEsCustom)
        {
            this.jLabel6.setText("DrvUrl: ");
            this.jLabel12.setText("DrvUrl: ");
        }
        else
        {
            this.jLabel6.setText("IP: ");
            this.jLabel12.setText("IP: ");
        }

        this.lSID.setVisible(bShowSID);
        this.jtSID.setVisible(bShowSID);
        this.lSID2.setVisible(bShowSID);
        this.jtSID2.setVisible(bShowSID);

        this.jLabel6.setVisible(bShowIPPort);
        this.jtIP.setVisible(bShowIPPort);
        this.jLabel7.setVisible(bShowIPPort && !bEsCustom);
        this.jtPuerto.setVisible(bShowIPPort && !bEsCustom);
        this.jButton7.setVisible(bShowIPPort && !bEsCustom);

        this.jLabel12.setVisible(bShowIPPort);
        this.jtIP2.setVisible(bShowIPPort);
        this.jLabel13.setVisible(bShowIPPort && !bEsCustom);
        this.jtPuerto2.setVisible(bShowIPPort && !bEsCustom);
        this.jButton6.setVisible(bShowIPPort && !bEsCustom);

        this.jLabel91.setVisible(bEsInformix);
        this.jLabel912.setVisible(bEsInformix);
        this.jtInfomixServer2.setVisible(bEsInformix);
        this.jtInfomixServer.setVisible(bEsInformix);
    }

    private void abrirConexion()
    {
        // Abrir Conexi�n
        if(sKey != null && sKey.length() > 0) {
            HashMap propconex = getHMConexion(sKey,Propiedades);

            jdbcDriverURL = "";
            if(propconex.containsKey("jdbcDriverURL"))
                jdbcDriverURL = propconex.get("jdbcDriverURL").toString();
           
            jdbcDriverClass = "";
            if(propconex.containsKey("jdbcDriverClass"))
                jdbcDriverClass = propconex.get("jdbcDriverClass").toString();
           
            user = "";
            if(propconex.containsKey("user"))
                user = propconex.get("user").toString();

            password = "";
            if(propconex.containsKey("password"))
                password = propconex.get("password").toString();
               
            // si el usuario esta vacio se pide
            if(user == null || user.trim().length() == 0)
            {
                EnterSingleData edata = new EnterSingleData(new JFrame(),true,
                        Gestor.GetLiteral("selectconexion.enter_user","Introduzca el usuario"),
                        Gestor.GetLiteral("selectconexion.user","Usuario"));
                edata.setVisible(true);
                if(edata.getReturnStatus() == edata.RET_OK)
                    user = edata.jTextField1.getText();
            }

            // si el password esta vacio se pide
            if(password == null || password.trim().length() == 0)
            {
                EnterSingleData edata = new EnterSingleData(new JFrame(),true,
                        Gestor.GetLiteral("selectconexion.enter_password","Introduzca la contrase�a"),
                        Gestor.GetLiteral("selectconexion.password","Contrase�a"));
                edata.setVisible(true);
                if(edata.getReturnStatus() == edata.RET_OK)
                    password = edata.jTextField1.getText();
            }

            // carga la clase
            try {
                Class.forName(jdbcDriverClass);
            } catch(java.lang.ClassNotFoundException nfe) {
                Trackbug.error(nfe, nfe.getMessage());
                // tenemos que sacar una ventana indicando que nos falta el driver jdbc y que tenemos que copiarlo al directorio
                // lib y rearancar el programa
                Alerta al = new Alerta(this, Gestor.GetLiteral("gestor.error_1","Error"), true,
                    Gestor.GetLiteral("conexiontxt.error_2","No se encuentran las clases correspondientes al driver jdbc de la base de datos.") +
                    "\n" + Gestor.GetLiteral("selectconexion.getdriver","Descargueselo de la web del fabricante de la BBDD o busquelo en 'http://developers.sun.com/product/jdbc/drivers'.") +
                    "\n" + Gestor.GetLiteral("selectconexion.copydriver","Cuando tenga el archivo JAR o ZIP c�pielo al directorio 'lib' del GestDB y rearranque el programa."), Alerta.OK);
                al.setVisible(true);
                al = null;
                return;
            }
               
            setAbrir(true);
            setVisible(false);

            String sAnchos = "";
            String anchos[] = new String[jtConexiones.getTableHeader().getColumnModel().getColumnCount()];
            for(int i=0; i < anchos.length; i++)
            {
                if(i > 0)
                    sAnchos += "-";
                sAnchos += String.valueOf(jtConexiones.getTableHeader().getColumnModel().getColumn(i).getPreferredWidth());
            }

            Gestor.propiedades.setProperty("selectconexion.table_columns_width",sAnchos);

            dispose();
        }   
    }

    /***
     * este m�todo permite preparra la url de conexi�n para ser utilizada desde otro sitio de la aplicaci�n
     * @param sKey clave de la conexi�n
     * @return un vector con los datos de la conexi�n que se corresponde con la clave que recive, o null si hay un error.
     *          El vector esta compuesto de; key, jdbcDriverURL, jdbcDriverClass, user,password
     */
    public static Vector prepararConexion(String sKey, Class clase)
    {
        Vector vResultados = new Vector();
        vResultados.addElement(sKey);

        if(sKey != null && sKey.length() > 0)
        {
            if(Propiedades == null)
            {
                Propiedades = Gestor.CargaConexiones(clase);
                if(Propiedades == null)
                    Propiedades = new Properties();
            }

            HashMap propconex = getHMConexion(sKey,Propiedades);

            if(propconex.containsKey("jdbcDriverURL"))
                vResultados.addElement(propconex.get("jdbcDriverURL").toString());
            else
                vResultados.addElement("");

            String jdbcDriverClass = "";
            if(propconex.containsKey("jdbcDriverClass"))
            {
                jdbcDriverClass = propconex.get("jdbcDriverClass").toString();
                vResultados.addElement(propconex.get("jdbcDriverClass").toString());
            }
            else
                vResultados.addElement("");

            String user = "";
            if(propconex.containsKey("user"))
                user = propconex.get("user").toString();

            String password = "";
            if(propconex.containsKey("password"))
                password = propconex.get("password").toString();

            // si el usuario esta vacio se pide
            if(user == null || user.trim().length() == 0)
            {
                EnterSingleData edata = new EnterSingleData(new JFrame(),true,
                        Gestor.GetLiteral("selectconexion.enter_user","Introduzca el usuario"),
                        Gestor.GetLiteral("selectconexion.user","Usuario"));
                edata.setVisible(true);
                if(edata.getReturnStatus() == edata.RET_OK)
                    user = edata.jTextField1.getText();
            }

            // si el password esta vacio se pide
            if(password == null || password.trim().length() == 0)
            {
                EnterSingleData edata = new EnterSingleData(new JFrame(),true,
                        Gestor.GetLiteral("selectconexion.enter_password","Introduzca la contrase�a"),
                        Gestor.GetLiteral("selectconexion.password","Contrase�a"));
                edata.setVisible(true);
                if(edata.getReturnStatus() == edata.RET_OK)
                    password = edata.jTextField1.getText();
            }

            vResultados.addElement(user);
            vResultados.addElement(password);

            // carga la clase
            try {
                Class.forName(jdbcDriverClass);
            } catch(java.lang.ClassNotFoundException nfe) {
                Trackbug.error(nfe, nfe.getMessage());
                // tenemos que sacar una ventana indicando que nos falta el driver jdbc y que tenemos que copiarlo al directorio
                // lib y rearancar el programa
                Alerta al = new Alerta(new Frame(), Gestor.GetLiteral("gestor.error_1","Error"), true,
                    Gestor.GetLiteral("conexiontxt.error_2","No se encuentran las clases correspondientes al driver jdbc de la base de datos.") +
                    "\n" + Gestor.GetLiteral("selectconexion.getdriver","Descargueselo de la web del fabricante de la BBDD o busquelo en 'http://developers.sun.com/product/jdbc/drivers'.") +
                    "\n" + Gestor.GetLiteral("selectconexion.copydriver","Cuando tenga el archivo JAR o ZIP c�pielo al directorio 'lib' del GestDB y rearranque el programa."), Alerta.OK);
                al.setVisible(true);
                al = null;
                return null;
            }

            return vResultados;
        }

        return null;
    }

    private void RellenaCamposConexion(JComboBox jcGestorA, JTextField jtIPA,
        JTextField jtSIDA, JTextField jtPuertoA, JTextField jtInfomixServerA,
        JTextField jtUsuarioA, JPasswordField jPasswordFieldA)
    {
        // saca las propiedades de la clave
        // en propiedades tenemos tres datos; jdbcurl;user;pass
        java.util.StringTokenizer st1 = new java.util.StringTokenizer(Propiedades.getProperty(sKey),";",false);

        HashMap hmConexion = getHMConexion(sKey, Propiedades);
        jtIPA.setText(hmConexion.containsKey("ip") (String)hmConexion.get("ip") : "");
        jtPuertoA.setText(hmConexion.containsKey("puerto") (String)hmConexion.get("puerto") : "");
        jtSIDA.setText(hmConexion.containsKey("sid") (String)hmConexion.get("sid") : "");
        jtUsuarioA.setText(hmConexion.containsKey("user") (String)hmConexion.get("user") : "");
        jPasswordFieldA.setText(hmConexion.containsKey("password") (String)hmConexion.get("password") : "");
        jtInfomixServerA.setText(hmConexion.containsKey("informixserver") (String)hmConexion.get("informixserver") : "");

        if(hmConexion.containsKey("gestor"))
        {
            if(((String)hmConexion.get("gestor")).equals(CUSTOM))
            {
                jtSIDA.setText(hmConexion.containsKey("jdbcDriverClass") (String)hmConexion.get("jdbcDriverClass") : "");
                jtIPA.setText(hmConexion.containsKey("jdbcDriverURL") (String)hmConexion.get("jdbcDriverURL") : "");
            }
            jcGestorA.getModel().setSelectedItem((String)hmConexion.get("gestor"));
            showProperties((String)hmConexion.get("gestor"));
        }
       
    }

    private boolean CompruebaCampos(JTextField jtNombreA, JComboBox jcGestorA, JTextField jtIPA,
        JTextField jtSIDA, JTextField jtPuertoA, JTextField jtInfomixServerA,
        JTextField jtUsuarioA, JPasswordField jPasswordFieldA, boolean bGuardar)
    {
        String opcion = (String)jcGestorA.getSelectedItem();
        boolean hayerror = false;
        // comprueba los campos obligatorios
        if(jtNombreA.getText().trim().length() == 0) {
            Alerta al = new Alerta(this, Gestor.GetLiteral("gestor.error_1","Error"), true,
                Gestor.GetLiteral("selectconexion.error_4","El nombre es obligatorio"), Alerta.OK);
            al.setVisible(true);
            al = null;
            hayerror = true;
        }
        else if(jtSIDA.getText().trim().length() == 0)
        {
            if(opcion.equals(SQLSERVER) != true && opcion.equals(SQL) != true && opcion.equals(SYBASE5) != true)
            {
                Alerta al = new Alerta(this, Gestor.GetLiteral("gestor.error_1","Error"), true,
                    Gestor.GetLiteral("selectconexion.error_4","El nombre es obligatorio"), Alerta.OK);

                if(opcion.equals(ORACLE) || opcion.equals(ORACLE_OCI_8) || opcion.equals(ORACLE_OCI_9)) al.ActivarOK(Gestor.GetLiteral("selectconexion.error_5","El SID es obligatorio"));
                if(opcion.equals(DB2) || opcion.equals(DB2_CAE) || opcion.equals(DB2_UNIVERSAL)) al.ActivarOK(Gestor.GetLiteral("selectconexion.error_5","El SID es obligatorio"));
                if(opcion.equals(ODBC)) al.ActivarOK(Gestor.GetLiteral("selectconexion.error_6","El DSN es obligatorio"));
                if(opcion.equals(MYSQL)) al.ActivarOK(Gestor.GetLiteral("selectconexion.error_8","El DBName es obligatorio"));
                if(opcion.equals(ADABASD) || opcion.equals(POSTGRESQL7) || opcion.equals(HYPERSQL_EMBEDDED) ||
                   opcion.equals(DAFFODILDB_EMBEDDED) || opcion.equals(DAFFODILDB_SERVER) || opcion.equals(H2_EMBEDDED) ||
                   opcion.equals(FIREBIRD) || opcion.equals(INSTANTDB314) || opcion.equals(MIMER) || opcion.equals(H2_SERVER) ||
                   opcion.equals(HYPERSONIC13) || opcion.equals(SAPDB) || opcion.equals(PERVASIVE) || opcion.equals(INGRES) ||
                   opcion.equals(POINTBASE_SERVER) || opcion.equals(POINTBASE_EMBEDDED) || opcion.equals(POINTBASE_MICRO) ||
                   opcion.equals(CLOUDSCAPE) || opcion.equals(CLOUDSCAPE_RMI) || opcion.equals(INTERBASE) ||
                   opcion.equals(DERBY_EMBEDDED) || opcion.equals(DERBY_EMBEDDED_MEMORY) || opcion.equals(DERBY_SERVER) ||
                   opcion.equals(CUBRID))
                    al.ActivarOK(Gestor.GetLiteral("selectconexion.error_7","El DB es obligatorio"));
                if(opcion.equals(INFORMIX)) al.ActivarOK(Gestor.GetLiteral("selectconexion.error_8","El DBName es obligatorio"));
                if(opcion.equals(INTESYSTEMS)) al.ActivarOK(Gestor.GetLiteral("selectconexion.error_13","El Namespace es obligatorio"));
                if(opcion.equals(CUSTOM)) al.ActivarOK(Gestor.GetLiteral("selectconexion.error_9","El Driver Class es obligatorio"));
                al.setVisible(true);
                al = null;
                hayerror = true;
            }
        }
        else if(!vOnlyDBName.contains(opcion)) // la ip y el puerto s�lo son obligatorios si el gestor es distinto de odbc, instantdb, y hypersonic
        {
            if(jtIPA.getText().trim().length() == 0) {
                Alerta al = new Alerta(this, Gestor.GetLiteral("gestor.error_1","Error"), true,
                    Gestor.GetLiteral("selectconexion.error_4","El nombre es obligatorio"), Alerta.OK);

                if(opcion.equals(CUSTOM))
                    al.ActivarOK(Gestor.GetLiteral("selectconexion.error_10","La Url Driver es obligatoria"));
                else
                    al.ActivarOK(Gestor.GetLiteral("selectconexion.error_11","La IP es obligatoria"));
                al.setVisible(true);
                al = null;
                hayerror = true;
            }
            else if(jtPuertoA.getText().trim().length() == 0 && !vOptionalPort.contains(opcion))
            { // el puerto no es obligatorio si es CUSTOM, H2 server, frontbase, hypersql server, interbase, intersystems cache
                Alerta al = new Alerta(this, Gestor.GetLiteral("gestor.error_1","Error"), true,
                    Gestor.GetLiteral("selectconexion.error_4","El nombre es obligatorio"), Alerta.OK);
                al.ActivarOK(Gestor.GetLiteral("selectconexion.error_12","El puerto es obligatorio"));
                al.setVisible(true);
                al = null;
                hayerror = true;
            }
        }
       
        if(hayerror == false) {
            // hay que componer la url
            String datos[] = ComponerUrl(opcion, jtSIDA.getText(), jtIPA.getText(), jtPuertoA.getText(),
                jtInfomixServerA.getText(), jtUsuarioA.getText(), String.valueOf(jPasswordFieldA.getPassword()));
            jdbcDriverURL = datos[0];
            jdbcDriverClass = datos[1];
           
            user = jtUsuarioA.getText().trim();
            password = String.valueOf(jPasswordFieldA.getPassword()).trim();
           
            if(Propiedades == null)
            {
                Propiedades = Gestor.CargaConexiones(this.getClass());
                if(Propiedades == null)
                    Propiedades = new Properties();
            }

            if(bGuardar)
            {
                Propiedades.setProperty(jtNombreA.getText().trim(),jdbcDriverURL + ";" + user + ";" + password);

                Gestor.GuardaConexiones(this.getClass(), Propiedades);
                CargaConexiones();
                ((CardLayout)jpCardLayout.getLayout()).first(jpCardLayout);
            }
        }

        return !hayerror;
    }
       
    public static String[] ComponerUrl(String gestor, String sid, String ip, String puerto, String servinformix, String usuario, String pass)
    {
        String datos[] = {"",""};
       
        if(gestor.equals(ADABASD)) {
            datos[0] = "jdbc:adabasd://" + ip.trim() + ":" + puerto.trim() + "/" + sid.trim();
            datos[1] = CLASS_ADABASD;
        }
        else if(gestor.equals(CLOUDSCAPE)) {
            datos[0] = "jdbc:cloudscape:" + sid.trim();
            datos[1] = CLASS_CLOUDSCAPE;
        }
        else if(gestor.equals(CLOUDSCAPE_RMI)) {
            datos[0] = "jdbc:rmi://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"") + "/jdbc:cloudscape:" + sid.trim();
            datos[1] = CLASS_CLOUDSCAPE_RMI;
        }
        else if(gestor.equals(CUBRID)) {
            datos[0] = "jdbc:cubrid:" + ip.trim() + ":" + ((puerto.trim().length() > 0)?puerto.trim():"") + ":" + ((sid.trim().length() > 0)?sid.trim():"") + ":::";
            datos[1] = CLASS_CUBRID;
        }
        else if(gestor.equals(DAFFODILDB_EMBEDDED)) {
            datos[0] = "jdbc:daffodilDB_embedded:" + sid.trim();
            datos[1] = CLASS_DAFFODILDB_EMBEDDED;
        }
        else if(gestor.equals(DAFFODILDB_SERVER)) {
            datos[0] = "jdbc:daffodilDB://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"") + "/" + sid.trim();
            datos[1] = CLASS_DAFFODILDB_SERVER;
        }
        else if(gestor.equals(DB2)) {
            datos[0] = "jdbc:db2://" + ip.trim() + ":" + puerto.trim() + "/" + sid.trim();
            datos[1] = CLASS_DB2;
        }
        else if(gestor.equals(DB2_CAE)) {
            datos[0] = "jdbc:DB2:" + sid.trim();
            datos[1] = CLASS_DB2_CAE;
        }
        else if(gestor.equals(DB2_UNIVERSAL)) {
            datos[0] = "jdbc:db2j:net://" + ip.trim() + ":" + puerto.trim() + "/" + sid.trim();
            datos[1] = CLASS_DB2_UNIVERSAL;
        }
        else if(gestor.equals(DERBY_SERVER)) {
            datos[0] = "jdbc:derby://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"") + "/" + sid.trim();
            datos[1] = CLASS_DERBY_SERVER;
        }
        else if(gestor.equals(DERBY_EMBEDDED_MEMORY)) {
            datos[0] = "jdbc:derby:memory:" + sid.trim();
            datos[1] = CLASS_DERBY_EMBEDDED;
        }
        else if(gestor.equals(DERBY_EMBEDDED)) {
            datos[0] = "jdbc:derby:" + sid.trim();
            datos[1] = CLASS_DERBY_EMBEDDED;
        }
        else if(gestor.equals(FIREBIRD)) {
            datos[0] = "jdbc:firebirdsql:" + ip.trim() + "/" + puerto.trim() + ":" + sid.trim();
            datos[1] = CLASS_FIREBIRD;
        }
        else if(gestor.equals(FIRSTSQL)) {
            datos[0] = "jdbc:dbcp://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"");
            datos[1] = CLASS_FIRSTSQL;
        }
        else if(gestor.equals(FRONTBASE)) {
            datos[0] = "jdbc:frontbase://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"") + ((sid.trim().length() > 0)?"/" + sid.trim():"");
            datos[1] = CLASS_FRONTBASE;
        }
        else if(gestor.equals(H2_EMBEDDED)) {
            datos[0] = "jdbc:h2:" + sid.trim();
            datos[1] = CLASS_H2;
        }
        else if(gestor.equals(H2_SERVER)) {
            datos[0] = "jdbc:h2:tcp://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"") + ((sid.trim().length() > 0)?"/" + sid.trim():"");
            datos[1] = CLASS_H2;
        }
        else if(gestor.equals(HYPERSONIC13)) {
            datos[0] = "jdbc:HypersonicSQL:" + sid.trim();
            datos[1] = CLASS_HYPERSONIC13;
        }
        else if(gestor.equals(HYPERSQL_EMBEDDED)) {
            datos[0] = "jdbc:hsqldb:" + sid.trim();
            datos[1] = CLASS_HYPERSQL;
        }
        else if(gestor.equals(HYPERSQL_SERVER)) {
            datos[0] = "jdbc:hsqldb:hsql://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"") + ((sid.trim().length() > 0)?"/" + sid.trim():"");
            datos[1] = CLASS_HYPERSQL;
        }
        else if(gestor.equals(INFORMIX)) {
            datos[0] = "jdbc:informix-sqli://" + ip.trim() +
            ":" + puerto.trim() + "/" + sid.trim() +
            ":INFORMIXSERVER=" + servinformix.trim() +
            ";user=" + usuario.trim() +
            ";password=" + pass.trim();
            datos[1] = CLASS_INFORMIX;
        }
        else if(gestor.equals(INGRES)) {
            datos[0] = "jdbc:ingres://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"") + ((sid.trim().length() > 0)?"/" + sid.trim():"");
            datos[1] = CLASS_INGRES;
        }
        else if(gestor.equals(INSTANTDB314)) {
            datos[0] = "jdbc:idb:" + sid.trim();
            datos[1] = CLASS_INSTANTDB314;
        }
        else if(gestor.equals(INTERBASE)) {
            datos[0] = "jdbc:interbase://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"") + "/" + sid.trim();
            datos[1] = CLASS_INTERBASE;
        }
        else if(gestor.equals(INTESYSTEMS)) {
            datos[0] = "jdbc:Cache://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"") + ((sid.trim().length() > 0)?"/" + sid.trim():"");
            datos[1] = CLASS_INTESYSTEMS;
        }
        else if(gestor.equals(JTDS_SQLSERVER)) {
            datos[0] = "jdbc:jtds:sqlserver://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"") +
                    ((sid.trim().length() > 0)?"/" + sid.trim():"");
            datos[1] = CLASS_JTDS;
        }
        else if(gestor.equals(JTDS_SYBASE)) {
            datos[0] = "jdbc:jtds:sybase://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"") +
                    ((sid.trim().length() > 0)?"/" + sid.trim():"");
            datos[1] = CLASS_JTDS;
        }
        else if(gestor.equals(MIMER)) {
            datos[0] = "jdbc:mimer://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"") + ((sid.trim().length() > 0)?"/" + sid.trim():"");
            datos[1] = CLASS_MIMER;
        }
        else if(gestor.equals(MYSQL)) {
            datos[0] = "jdbc:mysql://" + ip.trim() + ":" + puerto.trim() + "/" + sid.trim();
            datos[1] = CLASS_MYSQL;
        }
        else if(gestor.equals(ODBC)) {
            datos[0] = "jdbc:odbc:" + sid.trim();
            datos[1] = CLASS_ODBC;
        }
        else if(gestor.equals(ORACLE)) {
            datos[0] = "jdbc:oracle:thin:@" + ip.trim() + ":" + puerto.trim() + ":" + sid.trim();
            datos[1] = CLASS_ORACLE;
        }
        else if(gestor.equals(ORACLE_OCI_8)) {
            datos[0] = "jdbc:oracle:oci8:@" + sid.trim();
            datos[1] = CLASS_ORACLE;
        }
        else if(gestor.equals(ORACLE_OCI_9)) {
            datos[0] = "jdbc:oracle:oci:@" + sid.trim();
            datos[1] = CLASS_ORACLE;
        }
        else if(gestor.equals(PERVASIVE)) {
            datos[0] = "jdbc:pervasive://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"") + ((sid.trim().length() > 0)?"/" + sid.trim():"");
            datos[1] = CLASS_PERVASIVE;
        }
        else if(gestor.equals(POINTBASE_SERVER)) {
            datos[0] = "jdbc:pointbase:server://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"") + "/" + sid.trim();
            datos[1] = CLASS_POINTBASE;
        }
        else if(gestor.equals(POINTBASE_EMBEDDED)) {
            datos[0] = "jdbc:pointbase:embedded:" + sid.trim();
            datos[1] = CLASS_POINTBASE;
        }
        else if(gestor.equals(POINTBASE_MICRO)) {
            datos[0] = "jdbc:pointbase:micro:" + sid.trim();
            datos[1] = CLASS_POINTBASE_MICRO;
        }
        else if(gestor.equals(POSTGRESQL7)) {
            datos[0] = "jdbc:postgresql://" + ip.trim() + ":" + puerto.trim() + "/" + sid.trim();
            datos[1] = CLASS_MYSQL;
        }
        else if(gestor.equals(SAPDB)) {
            datos[0] = "jdbc:sapdb://" + ip.trim() + ((puerto.trim().length() > 0)?":" + puerto.trim():"") +
                    ((sid.trim().length() > 0)?"/" + sid.trim():"");
            // jdbc:sapdb://PARMA:9876/DEMODB?sqlmode=ORACLE&timeout=120  7299
            // no tratamos eel sqlmode que permite ORACLE o INTERNAL
            datos[1] = CLASS_SAPDB;
        }
        else if(gestor.equals(SQLSERVER)) {
            datos[0] = "jdbc:sqlserver://" + ip.trim() + ":" + puerto.trim();
            datos[1] = CLASS_SQLSERVER2005;
        }
        else if(gestor.equals(SQL)) {
            datos[0] = "jdbc:microsoft:sqlserver://" + ip.trim() + ":" + puerto.trim();
            datos[1] = CLASS_SQLSERVER;
        }
        else if(gestor.equals(SYBASE5)) {
            datos[0] = "jdbc:sybase:Tds:" + ip.trim() + ":" + puerto.trim();
            datos[1] = CLASS_SYBASE5;
        }
        else if(gestor.equals(CUSTOM)) {
            datos[0] = "custom:" + sid.trim() + "???" + ip.trim();
            datos[1] = sid.trim();
        }
        return datos;
    }
   
    public boolean wasCanceled() {
        return bCancelado;
    }
   

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        new SelectConexion(new javax.swing.JFrame(), true).setVisible(true);
    }
   
    public void CargaConexiones() {
        vConexiones.removeAllElements();
        // Tiene que cargar los datos de las conexiones.
        if(Propiedades == null) {
            Propiedades = Gestor.CargaConexiones(this.getClass());
        }
       
        if(Propiedades != null) {
            String stemp = null;
            for (Enumeration e = Propiedades.propertyNames() ; e.hasMoreElements() ;) {
                stemp = (String)e.nextElement();
                vConexiones.addElement(stemp);
            }
        }

        RellenaConexiones(grupoActual);
    }
   
    public String getjdbcDriverClass() {
        return jdbcDriverClass;
    }
   
    public String getjdbcDriverURL() {
        return jdbcDriverURL;
    }
   
    public String getuser() {
        return user;
    }
   
    public String getKey() {
        return sKey;
    }
   
    public String getpassword() {
        return password;
    }
   
    /** Getter for property abrir.
     * @return Value of property abrir.
     */
    public boolean isAbrir() {
        return abrir;
    }   
   
    /** Setter for property abrir.
     * @param abrir New value of property abrir.
     */
    private void setAbrir(boolean abrir) {
        this.abrir = abrir;
    }

    private void RellenaComboGrupos()
    {
        hmGrupos.clear();
        String sConexiones = "";
        for(int i=0,j=vConexiones.size();i<j;i++)
        {
            if(i!=0)
                sConexiones += ";" + (String)vConexiones.elementAt(i);
            else
                sConexiones += (String)vConexiones.elementAt(i);
        }
        hmGrupos.put(Gestor.GetLiteral("selectconexion.all_connection","Todas las conexiones"), sConexiones);
        cbGrupos.addItem(Gestor.GetLiteral("selectconexion.all_connection","Todas las conexiones"));
       
        Object oGrupos [] = Gestor.propiedades.entrySet().toArray();
        String nombre = null;
        for(int i=0;i<oGrupos.length;i++)
        {
            nombre = ((Map.Entry)oGrupos[i]).getKey().toString();
            if(nombre.indexOf("SelectConexion.grupo.") != -1)
            {
                // el nombre va despu�s del punto de la palabra grupo
                hmGrupos.put(nombre.substring(21), (String)Gestor.propiedades.get(nombre));
                cbGrupos.addItem(nombre.substring(21));
            }
        }
    }

    /**
     * Este metodo retorna un hashmap con las propiedades de la conexion.
     * La scadenas de conexi�n que entiende son las siguientes:
     * jdbc:adabasd://<HOST>:<PORT>/<DB>
     * jdbc:Cache://<host>:<port>/<namespace>
     * jdbc:cubrid:<host>:<port>:<DB>:::
     * jdbc:derby:[subsubprotocol:][databaseName][;attribute=value]*
     * jdbc:derby:myDB
     * jdbc:derby:../otherDirectory/myDB
     * jdbc:derby:c:/otherDirectory/myDB
     * jdbc:derby:jar:(c:/derby/lib/jar2.jar)jarDB2
     * jdbc:derby:memory:myDB
     * jdbc:derby:classpath:/myDB
     * jdbc:derby://localhost:1527/derbiedb
     * jdbc:cloudscape:<DB>
     * jdbc:daffodilDB_embedded:<DB>
     * jdbc:daffodilDB://<HOST>:<PORT>/<DB>
     * jdbc:db2://<HOST>:<PORT>/<SID>
     * jdbc:db2j:net://<HOST>:<PORT>/<SID>
     * jdbc:DB2:<SID>
     * jdbc:dbcp://<HOST>:<PORT>
     * jdbc:firebirdsql:<IP>/<PORT>:<SID>
     * jdbc:frontbase://<IP>[:<PORT>][/<DB>]
     * jdbc:h2:<DB>
     * jdbc:h2:tcp://<HOST>/<DB>
     * jdbc:hsqldb:<database>
     * jdbc:hsqldb:hsql://<host>:<port>
     * jdbc:HypersonicSQL:<DB>
     * jdbc:idb:<DB>
     * jdbc:informix-sqli://<HOST>:<PORT>/<SID>:INFORMIXSERVER=<InfomixServer>;user=<USER>;password=<PASS>; ...
     * jdbc:ingres://<HOST>:<PORT>/<DB>
     * jdbc:interbase://<HOST>/<DB>
     * jdbc:jtds:<server_type>://<server>[:<port>][/<database>][;<property>=<value>[;...]]
     * jdbc:microsoft:sqlserver://<HOST>:<PORT>
     * jdbc:mimer://<host>:<port>/<database>
     * jdbc:mysql://<HOST>:<PORT>/<SID>
     * jdbc:odbc:<DB>
     * jdbc:oracle:thin:@<HOST>:<PORT>:<SID>
     * jdbc:oracle:oci8:@<SID>
     * jdbc:oracle:oci:@<SID>
     * jdbc:pervasive://<host>:<port>/<database>
     * jdbc:pointbase:server://<HOST>[:<PORT>]/<DB>
     * jdbc:pointbase:embedded:<DB>
     * jdbc:pointbase:micro:<db_name>
     * jdbc:postgresql://<HOST>:<PORT>/<DB>
     * jdbc:rmi://<HOST>:<PORT>/jdbc:cloudscape:<DB>
     * jdbc:sybase:Tds:<HOST>:<PORT>
     * jdbc:sapdb://<database_computer>[:<port>]/<database_name>[?<option1>[&<option2>]...]
     * custom:<jdbcDriverClass>?<jdbcDriverURL>
     * @param sconexion Nombre de la conexi�n
     * @return hashmap con las propiedades de la conexion.<br>
     * Las propiedades que puede contener son:
     * gestor, jdbcDriverClass, jdbcDriverURL, user, password, sid, ip, puerto
     */
    public static HashMap getHMConexion(String sconexion, Properties Propiedades)
    {
        HashMap hmtmp = new HashMap(9);
       
        if(sconexion == null || Propiedades.getProperty(sconexion) == null)
        {
            Trackbug.info("Error conexion no exits: " + sconexion);
            return hmtmp;
        }

        // vamos con el usuario
        //  la url esta compuesta por una url + ";" + usuario + ";" + password.
        // en la url puede haber ";" por lo tanto no puedo utilizar Stringtokenizer con el ";" para sacar el usuario y contrase�a.
        String sConActual = Propiedades.getProperty(sconexion);
        int posPassword = sConActual.lastIndexOf(';');
        if(posPassword == -1)
        {
            Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error 1: la URL selecionada no es correcta.") + ", Conexion:" + sconexion);
            return hmtmp;
        }
       
        int posUsuario = sConActual.lastIndexOf(';',posPassword - 1);
        if(posUsuario == -1)
        {
            Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error 2: la URL selecionada no es correcta") + ", Conexion:" + sconexion);
            return hmtmp;
        }
       
        String suser = sConActual.substring(posUsuario + 1, posPassword);
        String spassword = sConActual.substring(posPassword + 1);
       
        String surl = sConActual.substring(0,posUsuario);

        java.util.StringTokenizer st2 = new java.util.StringTokenizer(surl,":",false);
        java.util.StringTokenizer st3 = null;
        boolean esCustom = false;

        // El primero es jdbc
        if(st2.hasMoreTokens() == false)
            Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error: la URL selecionada no es correcta") + ", Conexion:" + sconexion);
        else
        {  
            String stemp = st2.nextToken();
            if(stemp.equals("jdbc") == false && stemp.equals("custom") == false)
            {
                Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error: la URL selecionada no es correcta") + ", Conexion:" + sconexion);
                return hmtmp;
            }
            else if(stemp.equals("custom"))
                esCustom = true;
        }

        if(st2.hasMoreTokens() == false)
            Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error: la URL selecionada no es correcta") + ", Conexion:" + sconexion);
        else {
            // miramos el Gestor para coger el class
            String gestor = "";
            String sid = "";
            String ip = "";
            String puerto = "";
            String sjdbcDriverURL = "";
            String sjdbcDriverClass = "";
            String stemp = null;
            if(esCustom)
                gestor = CUSTOM;
            else
                gestor = (String)st2.nextToken();

            if (gestor.equals("adabasd")) // ADABASD
            {
                suser = suser.toUpperCase();
                spassword = spassword.toUpperCase();
            }
           
            hmtmp.put("keyjdbc",gestor);

            if(hmJDBC.containsKey(gestor))
                hmtmp.put("gestor",(String)hmJDBC.get(gestor));
            else
            {
                // es un caso especial, que puede ser m�s de un tipo de conexi�n contra el mismo gestor.
                if(gestor.toLowerCase().equals("db2"))
                {
                    if(surl.indexOf("db2://") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("db2://"));
                    else if(surl.toLowerCase().indexOf("db2:") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("db2:"));
                }
                else if(gestor.equals("derby"))
                {
                    if(surl.indexOf("derby://") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("derby://"));
                    else if(surl.indexOf("derby:memory:") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("derby:memory:"));
                    else if(surl.indexOf("derby:") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("derby:"));
                }
                else if(gestor.equals("h2"))
                {
                    if(surl.indexOf("h2:tcp://") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("h2:tcp://"));
                    else if(surl.indexOf("h2:") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("h2:"));
                }
                else if(gestor.equals("hsqldb"))
                {
                    if(surl.indexOf("hsqldb:hsql://") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("hsqldb:hsql://"));
                    else if(surl.indexOf("hsqldb:") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("hsqldb:"));
                }
                else if(gestor.equals("jtds"))
                {
                    if(surl.indexOf("jtds:sqlserver://") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("jtds:sqlserver://"));
                    else if(surl.indexOf("jtds:sybase://") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("jtds:sybase://"));
                }
                else if(gestor.equals("oracle"))
                {
                    if(surl.indexOf("oracle:thin:") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("oracle:thin:"));
                    else if(surl.indexOf("oracle:oci8:") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("oracle:oci8:"));
                    else if(surl.indexOf("oracle:oci:") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("oracle:oci:"));
                }
                else if(gestor.equals("pointbase"))
                {
                    if(surl.indexOf("pointbase:server://") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("pointbase:server://"));
                    else if(surl.indexOf("pointbase:embedded:") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("pointbase:embedded:"));
                    else if(surl.indexOf("pointbase:micro:") != -1)
                        hmtmp.put("gestor",(String)hmJDBC.get("pointbase:micro:"));
                }
                else if(gestor.equals("custom"))
                {
                    hmtmp.put("gestor",(String)hmJDBC.get("custom"));
                }
            }

            if (gestor.equals("oracle")) // ORACLE, ORACLE OCI 8i y OCI 9i
            {
                // jdbc:oracle:thin:@<HOST>:<PORT>:<SID>
                // jdbc:oracle:oci8:@<SID>
                // jdbc:oracle:oci:@<SID>
                sjdbcDriverURL = surl;
                sjdbcDriverClass = CLASS_ORACLE;
                int pos = surl.indexOf("@");
                if(pos != -1)
                {
                    st3 = new java.util.StringTokenizer(surl.substring(pos + 1),":",false);
                    if(surl.startsWith("jdbc:oracle:thin:"))
                    {
                        if(st3.hasMoreTokens() == false) { Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error: la URL selecionada no es correcta") + ", Conexion:" + sconexion);return hmtmp; }
                        hmtmp.put("ip",st3.nextToken());
                        if(st3.hasMoreTokens() == false) { Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error: la URL selecionada no es correcta") + ", Conexion:" + sconexion);return hmtmp; }
                        hmtmp.put("puerto",st3.nextToken());
                        if(st3.hasMoreTokens() == false) { Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error: la URL selecionada no es correcta") + ", Conexion:" + sconexion);return hmtmp; }
                        hmtmp.put("sid",st3.nextToken());
                    }
                    else
                    {
                        if(st3.hasMoreTokens() == false) { Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error: la URL selecionada no es correcta") + ", Conexion:" + sconexion);return hmtmp; }
                        hmtmp.put("sid",st3.nextToken());
                    }
                }
            }
            else if (gestor.equals("adabasd") ||
                    gestor.equals("postgresql") ||
                    gestor.equals("cubrid") ||
                    (gestor.equals("db2") && surl.indexOf("://") != -1)||
                    gestor.equals("db2j") ||
                    gestor.equals("mysql") ||
                    gestor.equals("microsoft") ||
                    gestor.equals("sapdb") ||
                    gestor.equals("dbcp") ||
                    gestor.equals("frontbase") ||
                    gestor.equals("ingres") ||
                    gestor.equals("Cache") ||
                    gestor.equals("mimer") ||
                    gestor.equals("pervasive") ||
                    gestor.equals("daffodilDB") ||
                    gestor.equals("jtds") ||
                    gestor.equals("interbase") ||
                    gestor.equals("sybase") ||
                    gestor.equals("rmi") ||
                    gestor.equals("sql") ||
                    gestor.equals("sqlserver") ) // ADABASD, POSTGRESQL, DB2, MYSQL, SQLSERVER, SAP maxDB, firstsql, frontbase, ingres,
                                          // intersystems, mimer, pervasive, DaffodilDB Server, JTDS para sqlserver y sybase, interbase, sybase
                                          // cloudscape RMI, CUBRID
            {
                // jdbc:adabasd://<HOST>:<PORT>/<DB>
                // jdbc:cubrid:<host>:<port>:<database>
                // jdbc:postgresql://<HOST>:<PORT>/<DB>
                // jdbc:db2j:net://<HOST>:<PORT>/<SID>
                // jdbc:db2://<HOST>:<PORT>/<SID>
                // jdbc:mysql://<HOST>:<PORT>/<SID>
                // jdbc:microsoft:sqlserver://<HOST>:<PORT>
                // jdbc:sapdb://<database_computer>[:<port>]/<database_name>[?<option1>[&<option2>]...]
                // jdbc:dbcp://local     // jdbc:dbcp://servercomputer:8000
                // jdbc:frontbase://host_name[:port][/database_name]
                // jdbc:ingres://NODENAME:PORT/DBNAME
                // jdbc:Cache://<host>:<port>/<namespace>
                // jdbc:mimer://<host>:<port>/<database>
                // jdbc:pervasive://<host>:<port>/<database>
                // jdbc:daffodilDB://<host>:<port3456>/<database>
                // jdbc:jtds:<server_type>://<server>[:<port>][/<database>][;<property>=<value>[;...]]
                // jdbc:interbase://<HOST>/<DB>
                // jdbc:sybase:Tds:<HOST>:<PORT>
                // jdbc:rmi://<HOST>:<PORT>/jdbc:cloudscape:<DB>
                sjdbcDriverURL = surl;
                if(gestor.equals("adabasd"))
                    sjdbcDriverClass = SelectConexion.CLASS_ADABASD;
                else if(gestor.equals("cubrid"))
                    sjdbcDriverClass = SelectConexion.CLASS_CUBRID;
                else if(gestor.equals("postgresql"))
                    sjdbcDriverClass = SelectConexion.CLASS_POSTGRESQL7;
                else if(gestor.equals("db2j"))
                    sjdbcDriverClass = SelectConexion.CLASS_DB2_UNIVERSAL;
                else if(gestor.equals("db2"))
                    sjdbcDriverClass = SelectConexion.CLASS_DB2;
                else if(gestor.equals("mysql"))
                    sjdbcDriverClass = SelectConexion.CLASS_MYSQL;
                else if(gestor.equals("sapdb"))
                    sjdbcDriverClass = SelectConexion.CLASS_SAPDB;
                else if(gestor.equals("sqlserver"))
                    sjdbcDriverClass = SelectConexion.CLASS_SQLSERVER2005;
                else if(gestor.equals("microsoft"))
                    sjdbcDriverClass = SelectConexion.CLASS_SQLSERVER;
                else if(gestor.equals("dbcp"))
                    sjdbcDriverClass = SelectConexion.CLASS_FIRSTSQL;
                else if(gestor.equals("frontbase"))
                    sjdbcDriverClass = SelectConexion.CLASS_FRONTBASE;
                else if(gestor.equals("ingres"))
                    sjdbcDriverClass = SelectConexion.CLASS_INGRES;
                else if(gestor.equals("Cache"))
                    sjdbcDriverClass = SelectConexion.CLASS_INTESYSTEMS;
                else if(gestor.equals("mimer"))
                    sjdbcDriverClass = SelectConexion.CLASS_MIMER;
                else if(gestor.equals("pervasive"))
                    sjdbcDriverClass = SelectConexion.CLASS_PERVASIVE;
                else if(gestor.equals("daffodilDB"))
                    sjdbcDriverClass = SelectConexion.CLASS_DAFFODILDB_SERVER;
                else if(gestor.equals("jtds"))
                    sjdbcDriverClass = SelectConexion.CLASS_JTDS;
                else if(gestor.equals("interbase"))
                    sjdbcDriverClass = SelectConexion.CLASS_INTERBASE;
                else if(gestor.equals("sybase"))
                    sjdbcDriverClass = SelectConexion.CLASS_SYBASE5;
                else if(gestor.equals("rmi"))
                    sjdbcDriverClass = SelectConexion.CLASS_CLOUDSCAPE_RMI;


                int pos = surl.indexOf("://");
                if(gestor.equals("sybase"))
                {
                    pos = surl.indexOf(":Tds:");
                    if(pos != -1)
                        pos += 2; // esto es para que la instrucci�n pos += 3 no falle y se ponga donde debe
                }
                else if(gestor.equals("cubrid"))
                {
                    pos = surl.indexOf(":cubrid:");
                    if(pos != -1)
                        pos += 5; // esto es para que la instrucci�n pos += 3 no falle y se ponga donde debe
                }

                if(pos != -1)
                {
                    pos += 3;
                    int pos2 = surl.indexOf(":",pos);
                    int pos3 = surl.indexOf("/",pos);
                   
                    if(gestor.equals("cubrid") && pos2 != -1) // para cubrid se utiliza : en lugar de /
                        pos3 = surl.indexOf(":",pos2 + 1);
                       
                    if(pos2 != -1 && (pos3 == -1 || pos3 > pos2)) // podriamos tener : de directorio como por ejemplo servidor/c:/ y no ser�a un puerto, los dos puntos tienes que estar delante de la barra
                    {
                        // hay puerto
                        hmtmp.put("ip",surl.substring(pos, pos2));
                        if(pos3 != -1) // hay sid
                        {
                            hmtmp.put("puerto", surl.substring(pos2 + 1, pos3));
                            if(gestor.equals("rmi"))
                                hmtmp.put("sid", surl.substring(pos3 + "/jdbc:cloudscape:".length()));
                            else
                            {
                                if(gestor.equals("cubrid") && pos2 != -1) // para cubrid tenemos que quitar lo que tengamos detras de los :
                                {
                                    int pos4 = surl.indexOf(":",pos3 + 1);
                                    if(pos4 != -1)
                                        hmtmp.put("sid", surl.substring(pos3 + 1, pos4));
                                    else
                                        hmtmp.put("sid", surl.substring(pos3 + 1));
                                }
                                else
                                    hmtmp.put("sid", surl.substring(pos3 + 1));
                            }
                        }
                        else
                            hmtmp.put("puerto", surl.substring(pos2 + 1));
                    }
                    else if(pos3 != -1) // hay sid y no hay puerto
                    {
                        hmtmp.put("ip",surl.substring(pos, pos3));
                        if(gestor.equals("rmi"))
                            hmtmp.put("sid", surl.substring(pos3 + "/jdbc:cloudscape:".length()));
                        else
                            hmtmp.put("sid", surl.substring(pos3 + 1));
                    }
                    else
                    {
                        hmtmp.put("ip",surl.substring(pos));
                    }
                }
            }
            else if (gestor.equals("firebirdsql")) // FIREBIRD
            {
                // jdbc:firebirdsql:<IP>/<PORT>:<SID>
                sjdbcDriverURL = surl;
                sjdbcDriverClass = CLASS_FIREBIRD;
                st3 = new java.util.StringTokenizer(surl.substring(17),":",false);

                if(st3.hasMoreTokens() == false) { Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error: la URL selecionada no es correcta") + ", Conexion:" + sconexion);return hmtmp; }
                java.util.StringTokenizer st4 = new java.util.StringTokenizer(st3.nextToken(),"/",false);
                if(st4.hasMoreTokens() == false) { Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error: la URL selecionada no es correcta") + ", Conexion:" + sconexion);return hmtmp; }
                hmtmp.put("ip",st4.nextToken());
                if(st4.hasMoreTokens() == false) { Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error: la URL selecionada no es correcta") + ", Conexion:" + sconexion);return hmtmp; }
                hmtmp.put("puerto",st4.nextToken());
                if(st3.hasMoreTokens() == false) { Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error: la URL selecionada no es correcta") + ", Conexion:" + sconexion);return hmtmp; }
                hmtmp.put("sid",st3.nextToken());
            }
            else if (gestor.equals("informix-sqli")) // INFORMIX
            {
                // jdbc:informix-sqli://<HOST>:<PORT>/<SID>:INFORMIXSERVER=<InfomixServer>;user=<USER>;password=<PASS>; ...
                sjdbcDriverURL = surl + ";" + suser + ";" + spassword;
                sjdbcDriverClass = CLASS_INFORMIX;
                st3 = new java.util.StringTokenizer(surl.substring(19),":",false);
                if(st3.hasMoreTokens() == false) { Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error: la URL selecionada no es correcta") + ", Conexion:" + sconexion);return hmtmp; }
                stemp = st3.nextToken();
                hmtmp.put("ip",stemp.substring(2));
                if(st3.hasMoreTokens() == false) { Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error: la URL selecionada no es correcta") + ", Conexion:" + sconexion);return hmtmp; }
                stemp = st3.nextToken();
                if(stemp.indexOf("/") != -1)
                {
                    hmtmp.put("puerto",stemp.substring(0,stemp.indexOf("/")));
                    hmtmp.put("sid",stemp.substring(stemp.indexOf("/")+1));
                }
                else
                {
                    hmtmp.put("puerto",stemp);
                    hmtmp.put("sid","");
                }
                if(st3.hasMoreTokens() == false) { Trackbug.error(null, Gestor.GetLiteral("selectconexion.error_1","Error: la URL selecionada no es correcta") + ", Conexion:" + sconexion);return hmtmp; }
                stemp = st3.nextToken();
                int pos = stemp.indexOf("=");
                if(pos != -1)
                {
                    int pos2 = stemp.indexOf(";");
                    if(pos2 != -1)
                        hmtmp.put("informixserver",stemp.substring(pos + 1,pos2));
                    else
                        hmtmp.put("informixserver",stemp.substring(pos + 1));
                }
            }
            else if (gestor.equals("h2") || gestor.equals("hsqldb") || gestor.equals("derby") || gestor.equals("pointbase"))
                // H2 embedded, H2 server, HyperSql embedded, HyperSql server, derby embedded memory y server, pointbase embedded, server y pointbase micro
            {
                // jdbc:h2:~/test  jdbc:h2:<DB>
                // jdbc:h2:tcp://localhost/~/test
                // jdbc:hsqldb:<database>
                // jdbc:hsqldb:hsql://<host>:<port>
                // jdbc:derby:[subsubprotocol:][databaseName][;attribute=value]*
                // jdbc:derby:myDB
                // jdbc:derby:../otherDirectory/myDB
                // jdbc:derby:c:/otherDirectory/myDB
                // jdbc:derby:jar:(c:/derby/lib/jar2.jar)jarDB2
                // jdbc:derby:memory:myDB
                // jdbc:derby:classpath:/myDB
                // jdbc:derby://localhost:1527/derbiedb
                // jdbcDriverURL = jdbc:pointbase:embedded:<DB>
                // jdbcDriverURL = jdbc:pointbase:micro:<db_name>
                // jdbcDriverURL = jdbc:pointbase:server://<HOST>[:<PORT>]/<DB>
                sjdbcDriverURL = surl;
                int pos = 0;
                int posData = 0;

                if(surl.startsWith("jdbc:h2:"))
                {
                    posData = "jdbc:h2:".length();
                    sjdbcDriverClass = CLASS_H2;
                }
                else if(surl.startsWith("jdbc:hsqldb:"))
                {
                    posData = "jdbc:hsqldb:".length();
                    sjdbcDriverClass = CLASS_HYPERSQL;
                }
                else if(surl.startsWith("jdbc:derby://"))
                {
                    sjdbcDriverClass = CLASS_DERBY_SERVER;
                }
                else  if(surl.startsWith("jdbc:derby:memory:"))
                {
                    posData = "jdbc:derby:memory:".length();
                    sjdbcDriverClass = CLASS_DERBY_EMBEDDED;
                }
                else  if(surl.startsWith("jdbc:derby:"))
                {
                    posData = "jdbc:derby:".length();
                    sjdbcDriverClass = CLASS_DERBY_EMBEDDED;
                }
                else if(surl.startsWith("jdbc:pointbase:embedded:"))
                {
                    posData = "jdbc:pointbase:embedded:".length();
                    sjdbcDriverClass = CLASS_POINTBASE;
                }
                else if(surl.startsWith("jdbc:pointbase:micro:"))
                {
                    posData = "jdbc:pointbase:micro:".length();
                    sjdbcDriverClass = CLASS_POINTBASE_MICRO;
                }
                else if(surl.startsWith("jdbc:pointbase:server:"))
                {
                    sjdbcDriverClass = CLASS_POINTBASE;
                }

                pos = surl.indexOf("://");
                if(pos != -1)
                {
                    pos += 3; // me salto ://
                    int pos2 = surl.indexOf(':',pos);
                    int pos3 = surl.indexOf('/',pos);

                    if(pos2 != -1 && (pos3 == -1 || pos3 > pos2)) // podriamos tener : de directorio como por ejemplo servidor/c:/ y no ser�a un puerto, los dos puntos tienes que estar delante de la barra
                    {
                        // tenemos puerto
                        hmtmp.put("ip",surl.substring(pos,pos2));
                        if(pos3 == -1)
                            hmtmp.put("puerto",surl.substring(pos2 + 1));
                        else
                        {
                            hmtmp.put("puerto",surl.substring(pos2 + 1, pos3));
                            hmtmp.put("sid",surl.substring(pos3 + 1));
                        }
                    }
                    else if(pos3 != -1)
                    {
                        // no tenemos puerto pero si tenemos database
                        hmtmp.put("ip",surl.substring(pos,pos3));
                        hmtmp.put("sid",surl.substring(pos3 + 1));
                    }
                }
                else
                {
                    hmtmp.put("sid",surl.substring(posData));
                }
            }
            else if (gestor.equals("odbc") || gestor.equals("idb") || gestor.equals("HypersonicSQL") || gestor.equals("cloudscape") ||
                    gestor.equals("daffodilDB_embedded") || gestor.toLowerCase().equals("db2")) // ODBC, instantdb, hypersonic, clodspace,DaffodilDB Embedded, db2 cae
            {
                // jdbc:odbc:<DB>
                // jdbc:idb:<DB>
                // jdbc:HypersonicSQL:<DB>
                // jdbc:cloudscape:<DB>
                // jdbc:daffodilDB_embedded:<database>
                // jdbc:DB2:<SID>
                sjdbcDriverURL = surl;
                if (gestor.equals(ODBC))
                    sjdbcDriverClass = CLASS_ODBC;
                else if(gestor.equals("idb"))
                    sjdbcDriverClass = CLASS_INSTANTDB314;
                else if(gestor.equals("HypersonicSQL"))
                    sjdbcDriverClass = CLASS_HYPERSONIC13;
                else if(gestor.equals("cloudscape"))
                    sjdbcDriverClass = CLASS_CLOUDSCAPE;
                else if(gestor.equals("daffodilDB_embedded"))
                    sjdbcDriverClass = CLASS_DAFFODILDB_EMBEDDED;
                else if(gestor.toLowerCase().equals("db2"))
                    sjdbcDriverClass = CLASS_DB2_CAE;

                int pos = surl.lastIndexOf(':');
                if(pos != -1)
                {
                    hmtmp.put("sid",surl.substring(pos + 1));
                }
            }
            else if (gestor.equals(CUSTOM)) // CUSf_cambio_passf_TOM
            {
                // va el jdbcDriverClass y jdbcDriverURL
                // estos estan detras del texto "custom:" y van separados por el caracter "???"
                int posInterrogacion = surl.substring(7).indexOf("???");
                if(posInterrogacion == -1)
                    posInterrogacion = surl.substring(7).indexOf("?");
                if(posInterrogacion != -1)
                {
                    sjdbcDriverClass = surl.substring(7).substring(0,posInterrogacion);
                    hmtmp.put("sid",sjdbcDriverClass);
                    sjdbcDriverURL = surl.substring(7).substring(posInterrogacion + 3);
                    hmtmp.put("ip",sjdbcDriverURL);
                }
                else
                    return hmtmp;
            }
            else  // No lo se
            {
                System.out.println(Gestor.GetLiteral("selectconexion.error_2","Error: El controlador JDBC") + " [" + surl + "] " + Gestor.GetLiteral("selectconexion.error_3","no esta contemplado"));
                return hmtmp;
            }

            hmtmp.put("jdbcDriverClass",sjdbcDriverClass);
            hmtmp.put("jdbcDriverURL",sjdbcDriverURL);
            hmtmp.put("user",suser);
            hmtmp.put("password",spassword);
           
        }
       
        return hmtmp;
    }
   
    public void PonLiterales()
    {
        grupoActual = Gestor.GetLiteral("selectconexion.all_connection","Todas las conexiones");
        setTitle(Gestor.GetLiteral("selectconexion.select_conection","Conexiones. Seleccione una conexi�n"));
        mdfGrupo.setText(Gestor.GetLiteral("selectconexion.modify","M"));
        jLabel3.setText(Gestor.GetLiteral("estructurabd.name","Nombre") + ": ");
        jLabel4.setText(Gestor.GetLiteral("selectconexion.gest_ddbb","Gestor BBDD") + ": ");
        jLabel7.setText(Gestor.GetLiteral("selectconexion.port","Puerto") + ": ");
        jLabel8.setText(Gestor.GetLiteral("selectconexion.user","Usuario") + ": ");
        jLabel9.setText(Gestor.GetLiteral("selectconexion.password","Contrase�a") + ": ");
        jButton3.setText(Gestor.GetLiteral("selectconexion.create_conection","Crear Conexi�n"));
        jLabel91.setText(Gestor.GetLiteral("selectconexion.informix_server","Servidor Informix") + ":");
        jLabel5.setText(Gestor.GetLiteral("estructurabd.name","Nombre") + ":");
        jLabel10.setText(Gestor.GetLiteral("selectconexion.gest_ddbb","Gestor BBDD") + ": ");
        jLabel13.setText(Gestor.GetLiteral("selectconexion.port","Puerto") + ":");
        jLabel14.setText(Gestor.GetLiteral("selectconexion.user","Usuario") + ":");
        jLabel15.setText(Gestor.GetLiteral("selectconexion.password","Contrase�a") + ":");
        jButton4.setText(Gestor.GetLiteral("selectconexion.accept_changes","Aceptar cambios"));
        jLabel912.setText(Gestor.GetLiteral("selectconexion.informix_server","Servidor Informix") + ":");
        jLabel1.setText(Gestor.GetLiteral("selectconexion.question_1","�Esta seguro que desea borrar la conexi�n?"));
        jlConexion.setText(Gestor.GetLiteral("selectconexion.connection","Conexi�n"));
        jButton1.setText(Gestor.GetLiteral("selectconexion.yes","Si"));
        jButton2.setText(Gestor.GetLiteral("selectconexion.no","No"));

        jLabel11.setText(Gestor.GetLiteral("selectconexion.create_conection","Crear Conexi�n"));
        jbCancelarCrear.setText(Gestor.GetLiteral("importardlg.cancel","Cancelar"));
        jbCancelarModificar.setText(Gestor.GetLiteral("importardlg.cancel","Cancelar"));
       
        jlGestor.setText(Gestor.GetLiteral("estructurabd.gestor","Gestor") + ": ");
        jlGrupo.setText(Gestor.GetLiteral("selectconexion.group","Grupo") + ": ");
        jlNombre.setText(Gestor.GetLiteral("estructurabd.name","Nombre") + ": ");
        jbCrear.setText(Gestor.GetLiteral("selectconexion.create","Crear"));
        jbModificar.setText(Gestor.GetLiteral("selectconexion.modify2","Modificar"));
        jbCopiar.setText(Gestor.GetLiteral("selectconexion.copy","Copiar"));
        jbBorrar.setText(Gestor.GetLiteral("selectconexion.delete","Borrar"));
        jbConectar.setText(Gestor.GetLiteral("gestor.button_connect","Conectar"));

        jbProbarConex.setText(Gestor.GetLiteral("selectconexion.button_test","Probar conexi�n"));
        jbProbarConex2.setText(Gestor.GetLiteral("selectconexion.button_test","Probar conexi�n"));

        titulos[0] = Gestor.GetLiteral("estructurabd.name","Nombre");
        titulos[1] = Gestor.GetLiteral("estructurabd.gestor","Gestor");
        titulos[2] = "SID";
        titulos[3] = Gestor.GetLiteral("selectconexion.user","Usuario");
        titulos[4] = "IP";
        titulos[5] = Gestor.GetLiteral("selectconexion.port","Puerto");
    }   
   
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addGrupo;
    private javax.swing.JComboBox cbGrupos;
    private javax.swing.JButton delGrupo;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JLabel jLabel91;
    private javax.swing.JLabel jLabel912;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPasswordField jPasswordField1;
    private javax.swing.JPasswordField jPasswordField2;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JButton jbBorrar;
    private javax.swing.JButton jbCancelarCrear;
    private javax.swing.JButton jbCancelarModificar;
    private javax.swing.JButton jbConectar;
    private javax.swing.JButton jbCopiar;
    private javax.swing.JButton jbCrear;
    private javax.swing.JButton jbModificar;
    private javax.swing.JButton jbProbarConex;
    private javax.swing.JButton jbProbarConex2;
    private javax.swing.JButton jbVerPassword;
    private javax.swing.JButton jbVerPassword2;
    private javax.swing.JComboBox jcGestor;
    private javax.swing.JComboBox jcGestor2;
    private javax.swing.JComboBox jcbGestores;
    private javax.swing.JLabel jlConexion;
    private javax.swing.JLabel jlGestor;
    private javax.swing.JLabel jlGrupo;
    private javax.swing.JLabel jlNombre;
    private javax.swing.JLabel jlTitleModificar;
    private javax.swing.JPanel jpBorrar;
    private javax.swing.JPanel jpCardLayout;
    private javax.swing.JPanel jpConexiones;
    private javax.swing.JPanel jpCrear;
    private javax.swing.JPanel jpFiltros;
    private javax.swing.JPanel jpFiltrosTipo;
    private javax.swing.JPanel jpGrupos;
    private javax.swing.JPanel jpModificar;
    private javax.swing.JPanel jpNombre;
    private javax.swing.JTable jtConexiones;
    private javax.swing.JTextField jtIP;
    private javax.swing.JTextField jtIP2;
    private javax.swing.JTextField jtInfomixServer;
    private javax.swing.JTextField jtInfomixServer2;
    private javax.swing.JTextField jtNombre;
    private javax.swing.JTextField jtNombre2;
    private javax.swing.JTextField jtPuerto;
    private javax.swing.JTextField jtPuerto2;
    private javax.swing.JTextField jtSID;
    private javax.swing.JTextField jtSID2;
    private javax.swing.JTextField jtUsuario;
    private javax.swing.JTextField jtUsuario2;
    private javax.swing.JTextField jtfNombreFiltro;
    private javax.swing.JLabel lSID;
    private javax.swing.JLabel lSID2;
    private javax.swing.JButton mdfGrupo;
    // End of variables declaration//GEN-END:variables
   
    private static Properties Propiedades = null; // en propiedades tenemos todas las conexiones, sus valores contiene tres datos; jdbcurl;user;pass
    private HashMap hmGrupos = new HashMap();
    private Vector vConexiones = new Vector(); // se utiliza para tener en algun sitio todas las conexiones por si
                                                // seleccionas el grupo de todas las conexiones
    private tmodelTabla tm = null;
    private String titulos[] = {"Nombre", "Gestor", "SID", "User", "IP", "Puerto"};
    private boolean canEdit[] = false, false, false, false, false, false };
    private Class clases[] = String.class, String.class, String.class, String.class, String.class, String.class };

    private String sKey = "";
    private String grupoActual = "Todas las conexiones";
   
    private String jdbcDriverClass = "";
    private String jdbcDriverURL = "";
    private String user = "";
    private String password = "";
    private boolean abrir = false;
   
    public final static String ADABASD = "adabasd";
    public final static String CLOUDSCAPE = "Cloudscape";
    public final static String CLOUDSCAPE_RMI = "Cloudscape RMI";
    public final static String CUBRID = "cubrid";
    public final static String CUSTOM = "custom";
    public final static String DAFFODILDB_EMBEDDED = "DaffodilDB Embedded";
    public final static String DAFFODILDB_SERVER = "DaffodilDB Server";
    public final static String DB2 = "db2";
    public final static String DB2_CAE = "db2 CAE";
    public final static String DB2_UNIVERSAL = "db2 Universal";
    public final static String DERBY_EMBEDDED = "Derby embedded";
    public final static String DERBY_EMBEDDED_MEMORY = "Derby embedded memory";
    public final static String DERBY_SERVER = "Derby server";
    public final static String FIREBIRD = "firebirdsql";
    public final static String FIRSTSQL = "firstsql";
    public final static String FRONTBASE = "FrontBase";
    public final static String H2_EMBEDDED = "H2 Embedded";
    public final static String H2_SERVER = "H2 Server";
    public final static String HYPERSONIC13 = "Hypersonic SQL v1.3";
    public final static String HYPERSQL_EMBEDDED = "HyperSQL embedded";
    public final static String HYPERSQL_SERVER = "HyperSQL server";
    public final static String INFORMIX = "informix-sqli";
    public final static String INGRES = "Ingres";
    public final static String INSTANTDB314 = "InstantDB v3.14";
    public final static String INTERBASE = "Interbase";
    public final static String INTESYSTEMS = "InterSystems Cache";
    public final static String JTDS_SQLSERVER = "JTDS Sqlserver";
    public final static String JTDS_SYBASE = "JTDS Sybase";
    public final static String MIMER = "Mimer";
    public final static String MYSQL = "mysql";
    public final static String ODBC = "odbc";
    public final static String ORACLE = "oracle";
    public final static String ORACLE_OCI_8 = "oracle oci 8i";
    public final static String ORACLE_OCI_9 = "oracle oci 9i";
    public final static String PERVASIVE = "Pervasive";
    public final static String POINTBASE_SERVER = "PointBase Server";
    public final static String POINTBASE_EMBEDDED = "PointBase Embedded";
    public final static String POINTBASE_MICRO = "PointBase Micro";
    public final static String POSTGRESQL7 = "postgresql 7.0";
    public final static String SAPDB = "Sap MaxDB";
    public final static String SQL = "microsoft Driver JDBC Sqlserver 2000";
    public final static String SQLSERVER = "sqlserver Driver JDBC Sqlserver 2005";
// com.microsoft.jdbc.SqlServer.SqlServerDriver   sql 2000  jdbc:microsoft:sqlserver://servidor:1433
// com.microsoft.sqlserver.jdbc.SQLServerDriver   sql 2005  jdbc:sqlserver://localhost:1433;databaseName=p1
// com.microsoft.sqlserver.jdbc.SQLServerDriver             jdbc:sqlserver://sql
    public final static String SYBASE5 = "Sybase 5.2";

    public final static String PUERTO_ADABASD = "7200";
    public final static String PUERTO_CLOUDSCAPE_RMI = "1527";
    public final static String PUERTO_CUBRID = "33000";
    public final static String PUERTO_DAFFODILDB = "3456";
    public final static String PUERTO_DB2 = "6789";
    public final static String PUERTO_DERBY = "1527";
    public final static String PUERTO_FIREBIRD = "3050";
    public final static String PUERTO_FIRSTSQL = "8000";
    public final static String PUERTO_INFORMIX = "1533";
    public final static String PUERTO_INGRES = "II7";
    public final static String PUERTO_MYSQL = "3306";
    public final static String PUERTO_ORACLE = "1521";
    public final static String PUERTO_POINTBASE = "9092";
    public final static String PUERTO_POSTGRESQL = "5432";
    public final static String PUERTO_SAPDB = "7299";
    public final static String PUERTO_SQL = "1433";
    public final static String PUERTO_SYBASE = "2048";

    public final static String CLASS_ADABASD = "de.sag.jdbc.adabasd.ADriver";
    public final static String CLASS_CLOUDSCAPE = "COM.cloudscape.core.JDBCDriver";
    public final static String CLASS_CLOUDSCAPE_RMI = "RmiJdbc.RJDriver";
    public final static String CLASS_CUBRID = "cubrid.jdbc.driver.CUBRIDDriver";
    public final static String CLASS_DAFFODILDB_EMBEDDED = "in.co.daffodil.db.jdbc.DaffodilDBDriver";
    public final static String CLASS_DAFFODILDB_SERVER = "in.co.daffodil.db.rmi.RmiDaffodilDBDriver";
    public final static String CLASS_DB2 = "COM.ibm.db2.jdbc.net.DB2Driver";
    public final static String CLASS_DB2_CAE = "COM.ibm.db2.jdbc.app.DB2Driver";
    public final static String CLASS_DB2_UNIVERSAL = "com.ibm.db2.jcc.DB2Driver";
    public final static String CLASS_DERBY_EMBEDDED = "org.apache.derby.jdbc.EmbeddedDriver";
    public final static String CLASS_DERBY_SERVER = "org.apache.derby.jdbc.ClientDriver";
    public final static String CLASS_FIREBIRD = "org.firebirdsql.jdbc.FBDriver";
    public final static String CLASS_FIRSTSQL = "COM.FirstSQL.Dbcp.DbcpDriver";
    public final static String CLASS_FRONTBASE = "com.frontbase.jdbc.FBJDriver";
    public final static String CLASS_H2 = "org.h2.Driver";
    public final static String CLASS_HYPERSONIC13 = "org.hsql.jdbcDriver";
    public final static String CLASS_HYPERSQL = "org.hsqldb.jdbcDriver";
    public final static String CLASS_INFORMIX = "com.informix.jdbc.IfxDriver";
    public final static String CLASS_INGRES = "com.ingres.jdbc.IngresDriver";
    public final static String CLASS_INSTANTDB314 = "org.enhydra.instantdb.jdbc.idbDriver";
    public final static String CLASS_INTERBASE = "interbase.interclient.Driver";
    public final static String CLASS_INTESYSTEMS = "com.intersys.jdbc.CacheDriver";
    public final static String CLASS_JTDS = "net.sourceforge.jtds.jdbc.Driver";
    public final static String CLASS_MYSQL = "com.mysql.jdbc.Driver";
    public final static String CLASS_MIMER = "com.mimer.jdbc.Driver";
    public final static String CLASS_ODBC = "sun.jdbc.odbc.JdbcOdbcDriver";
    public final static String CLASS_ORACLE = "oracle.jdbc.driver.OracleDriver";
    public final static String CLASS_PERVASIVE = "com.pervasive.jdbc.v2.Driver";
    public final static String CLASS_POINTBASE = "com.pointbase.jdbc.jdbcUniversalDriver";
    public final static String CLASS_POINTBASE_MICRO = "com.pointbase.me.jdbc.jdbcDriver ";
    public final static String CLASS_POSTGRESQL7 = "org.postgresql.Driver";
    public final static String CLASS_SAPDB = "com.sap.dbtech.jdbc.DriverSapDB";
    public final static String CLASS_SQLSERVER = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    public final static String CLASS_SQLSERVER2005 = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
    public final static String CLASS_SYBASE5 = "com.sybase.jdbc2.jdbc.SybDriver";

    public final static String CONEXIONES[] = {ADABASD,CLOUDSCAPE, CLOUDSCAPE_RMI, CUBRID, DAFFODILDB_EMBEDDED, DAFFODILDB_SERVER, DB2, DB2_CAE,
        DB2_UNIVERSAL, DERBY_EMBEDDED, DERBY_EMBEDDED_MEMORY, DERBY_SERVER, FIREBIRD, FIRSTSQL, FRONTBASE, H2_EMBEDDED, H2_SERVER,
        HYPERSONIC13, HYPERSQL_EMBEDDED, HYPERSQL_SERVER , INFORMIX, INGRES, INSTANTDB314, INTERBASE, INTESYSTEMS, JTDS_SQLSERVER,
        JTDS_SYBASE, MIMER, MYSQL,ODBC,ORACLE, ORACLE_OCI_8, ORACLE_OCI_9, PERVASIVE, POINTBASE_SERVER, POINTBASE_EMBEDDED, POINTBASE_MICRO,
        POSTGRESQL7, SAPDB, SQL, SQLSERVER, SYBASE5, CUSTOM};

    public static HashMap hmPUERTOS = null;
    public static HashMap hmSID = null;
    public static Vector vOnlyDBName = null;
    public static Vector vOnlyHostPort = null;
    public static Vector vOptionalPort = null;
    public static HashMap hmJDBC = null;

    static {
        hmPUERTOS = new HashMap();
        hmPUERTOS.put(ADABASD, PUERTO_ADABASD);
        hmPUERTOS.put(CLOUDSCAPE_RMI, PUERTO_CLOUDSCAPE_RMI);
        hmPUERTOS.put(CUBRID, PUERTO_CUBRID);
        hmPUERTOS.put(DAFFODILDB_SERVER, PUERTO_DAFFODILDB);
        hmPUERTOS.put(DB2, PUERTO_DB2);
        hmPUERTOS.put(DB2_UNIVERSAL, PUERTO_DB2);
        hmPUERTOS.put(DERBY_SERVER, PUERTO_DERBY);
        hmPUERTOS.put(FIREBIRD, PUERTO_FIREBIRD);
        hmPUERTOS.put(FIRSTSQL, PUERTO_FIRSTSQL);
        hmPUERTOS.put(INFORMIX, PUERTO_INFORMIX);
        hmPUERTOS.put(INGRES, PUERTO_INGRES);
        hmPUERTOS.put(JTDS_SQLSERVER, PUERTO_SQL);
        hmPUERTOS.put(JTDS_SYBASE, PUERTO_SYBASE);
        hmPUERTOS.put(MYSQL, PUERTO_MYSQL);
        hmPUERTOS.put(ORACLE, PUERTO_ORACLE);
        hmPUERTOS.put(POINTBASE_SERVER, PUERTO_POINTBASE);
        hmPUERTOS.put(POSTGRESQL7, PUERTO_POSTGRESQL);
        hmPUERTOS.put(SAPDB, PUERTO_SAPDB);
        hmPUERTOS.put(SQLSERVER, PUERTO_SQL);
        hmPUERTOS.put(SQL, PUERTO_SQL);
        hmPUERTOS.put(SYBASE5, PUERTO_SYBASE);

        hmSID = new HashMap();
        hmSID.put(ADABASD, "Server DB: ");
        hmSID.put(CLOUDSCAPE, "DB: ");
        hmSID.put(CLOUDSCAPE_RMI, "DB: ");
        hmSID.put(CUBRID, "DB: ");
        hmSID.put(CUSTOM, "DrvrClass: ");
        hmSID.put(DAFFODILDB_EMBEDDED, "DB: ");
        hmSID.put(DAFFODILDB_SERVER, "DB: ");
        hmSID.put(DB2, "SID: ");
        hmSID.put(DB2_CAE, "SID: ");
        hmSID.put(DB2_UNIVERSAL, "SID: ");
        hmSID.put(DERBY_EMBEDDED, "DB: ");
        hmSID.put(DERBY_EMBEDDED_MEMORY, "DB: ");
        hmSID.put(DERBY_SERVER, "DB: ");
        hmSID.put(FIREBIRD, "DB: ");
        hmSID.put(FIRSTSQL, "DB: ");
        hmSID.put(FRONTBASE, "DB: ");
        hmSID.put(H2_EMBEDDED, "DB: ");
        hmSID.put(H2_SERVER, "DB: ");
        hmSID.put(HYPERSONIC13, "DB: ");
        hmSID.put(HYPERSQL_EMBEDDED, "DB: ");
        hmSID.put(HYPERSQL_SERVER, "DB: ");
        hmSID.put(INFORMIX, "DBName: ");
        hmSID.put(INGRES, "DB: ");
        hmSID.put(INSTANTDB314, "DB: ");
        hmSID.put(INTERBASE, "DB: ");
        hmSID.put(INTESYSTEMS, "Namespace: ");
        hmSID.put(JTDS_SQLSERVER, "SID: ");
        hmSID.put(JTDS_SYBASE, "DB: ");
        hmSID.put(MIMER, "DB: ");
        hmSID.put(MYSQL, "DBName: ");
        hmSID.put(ODBC, "DSN: ");
        hmSID.put(ORACLE, "SID: ");
        hmSID.put(ORACLE_OCI_8, "SID: ");
        hmSID.put(ORACLE_OCI_9, "SID: ");
        hmSID.put(PERVASIVE, "DB: ");
        hmSID.put(POINTBASE_SERVER, "DB: ");
        hmSID.put(POINTBASE_EMBEDDED, "DB: ");
        hmSID.put(POINTBASE_MICRO, "DB: ");
        hmSID.put(POSTGRESQL7, "DB: ");
        hmSID.put(SQLSERVER, "SID: ");
        hmSID.put(SQL, "SID: ");
        hmSID.put(SAPDB, "DB: ");

        vOnlyDBName = new Vector();
        vOnlyDBName.addElement(CLOUDSCAPE);
        vOnlyDBName.addElement(DAFFODILDB_EMBEDDED);
        vOnlyDBName.addElement(DB2_CAE);
        vOnlyDBName.addElement(DERBY_EMBEDDED);
        vOnlyDBName.addElement(DERBY_EMBEDDED_MEMORY);
        vOnlyDBName.addElement(H2_EMBEDDED);
        vOnlyDBName.addElement(HYPERSONIC13);
        vOnlyDBName.addElement(HYPERSQL_EMBEDDED);
        vOnlyDBName.addElement(INSTANTDB314);
        vOnlyDBName.addElement(ODBC);
        vOnlyDBName.addElement(ORACLE_OCI_8);
        vOnlyDBName.addElement(ORACLE_OCI_9);
        vOnlyDBName.addElement(POINTBASE_EMBEDDED);
        vOnlyDBName.addElement(POINTBASE_MICRO);

        vOnlyHostPort = new Vector();
        vOnlyHostPort.addElement(FIRSTSQL);
        vOnlyHostPort.addElement(SQL);
        vOnlyHostPort.addElement(SQLSERVER);
        vOnlyHostPort.addElement(SYBASE5);

        vOptionalPort = new Vector();
        vOptionalPort.addElement(CUSTOM);
        vOptionalPort.addElement(H2_SERVER);
        vOptionalPort.addElement(FRONTBASE);
        vOptionalPort.addElement(HYPERSQL_SERVER);
        vOptionalPort.addElement(INTERBASE);
        vOptionalPort.addElement(INTESYSTEMS);
        vOptionalPort.addElement(PERVASIVE);

        hmJDBC = new HashMap();
        hmJDBC.put("adabasd",ADABASD);
        hmJDBC.put("cloudscape",CLOUDSCAPE);
        hmJDBC.put("cubrid",CUBRID);
        hmJDBC.put("rmi",CLOUDSCAPE_RMI);
        hmJDBC.put("daffodilDB_embedded",DAFFODILDB_EMBEDDED);
        hmJDBC.put("daffodilDB",DAFFODILDB_SERVER);
        hmJDBC.put("db2://",DB2);
        hmJDBC.put("db2:",DB2_CAE);
        hmJDBC.put("db2j",DB2_UNIVERSAL);
        hmJDBC.put("derby:",DERBY_EMBEDDED);
        hmJDBC.put("derby:memory:",DERBY_EMBEDDED_MEMORY);
        hmJDBC.put("derby://",DERBY_SERVER);
        hmJDBC.put("firebirdsql",FIREBIRD);
        hmJDBC.put("dbcp",FIRSTSQL);
        hmJDBC.put("frontbase",FRONTBASE);
        hmJDBC.put("h2:",H2_EMBEDDED);
        hmJDBC.put("h2:tcp://",H2_SERVER);
        hmJDBC.put("HypersonicSQL",HYPERSONIC13);
        hmJDBC.put("hsqldb:",HYPERSQL_EMBEDDED);
        hmJDBC.put("hsqldb:hsql://",HYPERSQL_SERVER);
        hmJDBC.put("informix-sqli",INFORMIX);
        hmJDBC.put("ingres",INGRES);
        hmJDBC.put("idb",INSTANTDB314);
        hmJDBC.put("interbase",INTERBASE);
        hmJDBC.put("Cache",INTESYSTEMS);
        hmJDBC.put("jtds:sqlserver://",JTDS_SQLSERVER);
        hmJDBC.put("jtds:sybase://",JTDS_SYBASE);
        hmJDBC.put("mimer",MIMER);
        hmJDBC.put("mysql",MYSQL);
        hmJDBC.put("odbc",ODBC);
        hmJDBC.put("oracle:thin:",ORACLE);
        hmJDBC.put("oracle:oci8:",ORACLE_OCI_8);
        hmJDBC.put("oracle:oci:",ORACLE_OCI_9);
        hmJDBC.put("pervasive",PERVASIVE);
        hmJDBC.put("pointbase:server://",POINTBASE_SERVER);
        hmJDBC.put("pointbase:embedded:",POINTBASE_EMBEDDED);
        hmJDBC.put("pointbase:micro:",POINTBASE_MICRO);
        hmJDBC.put("postgresql",POSTGRESQL7);
        hmJDBC.put("sapdb",SAPDB);
        hmJDBC.put("microsoft",SQL);
        hmJDBC.put("sqlserver",SQLSERVER);
        hmJDBC.put("sybase",SYBASE5);
        hmJDBC.put("custom",CUSTOM);
    }

    private boolean bCancelado = false;
    private long milisegundos = 0;   
    private SortTModel stm1 = null;

}
TOP

Related Classes of com.GestDB.sql.SelectConexion

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.