Q: Getting all databases from ResultSet I have a quick question. In my SQL manager I'm trying to make the 'show databases' of mysql, but when I execute the ResultSet it'd only set the last database name it founds into my jTextPane... How can I make it to show me all the databases existing on mysql? Here's the code I'm using...
if(validar[0].equals("mostrar") && validar[1].equals("bds")){
                            try{
                                if(validar.length == 2){                                        
                                    ResultSet rs = conexion.getMetaData().getCatalogs();                                        
                                    while (rs.next()){                                            
                                        jTextPane2.setText("BASE DE DATOS EXISTENTES = " + rs.getString("TABLE_CAT"));
                                        System.out.println("BASE DE DATOS EXISTENTES = " + rs.getString("TABLE_CAT"));
                                        jTextField1.setText("");
                                    }                                     
                                }else{
                                    jTextPane2.setText("ERROR.");
                                    jTextField1.setText("");
                                }                              
                            }catch(Exception ae){
                                jTextPane2.setText(ae.getMessage());
                                jTextField1.setText("");
                            }
                        }else{
                            jTextPane2.setText("ERROR: COMANDO MAL INGRESADO...");  
                        }

The System.out.println prints into the Output all the existing databases, but the jTextPane2.setText doesn't and thats what I want... Maybe adding a loop? I dont know!

A: You are overwriting the content of your jTextPane2 every time you use setText. Concatenate the string to the jTextPane2 content instead:
jTextPane2.setText(jTextPane2.getText()+
  "BASE DE DATOS EXISTENTES = " + rs.getString("TABLE_CAT"));

This will get you all the text in the text pane. You might want to do something about the alignment ;)
