Allora ragazzi ho risolto il dubbio per quanto riguarda l'eriditarietà.
Ora in questa classe ho il seguente metodo:
codice:
public String Nome_Person(String Nometabella){
int conta;
try{
//STEP 2: Register JDBC driver
Class.forName("com.mysql.jdbc.Driver");
//STEP 3: Open a connection
System.out.println("Connecting to database...");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/", "root","");
//STEP 4: Execute a query
System.out.println("Creating database...");
stmt = conn.createStatement();
String sql = "USE STUDENTS;";
stmt.executeUpdate(sql);
String queryfinal="SELECT* FROM ";
String querytabella=queryfinal.concat(Nometabella).concat(";");
System.out.println(""+querytabella);
ResultSet rs = stmt.executeQuery(querytabella);
conta=this.query3(Nometabella);
while (rs.next()) {
Nome2=rs.getString("Nome");
Cognome2=rs.getString("Cognome");
pers=new Person(Nome2,Cognome2);
pers.setNome(Nome2);
pers.setCognome(Cognome2);
Nomeperson=new String[conta];
for(int i=0;i<conta;i++){
Nomeperson[i]=pers.getNome();
System.out.println("Nome persona"+Nomeperson[i]);
}
}
//Create and set up the window.
System.out.println("Database created successfully...");
}catch(SQLException se){
//Handle errors for JDBC
se.printStackTrace();
}catch(Exception e){
//Handle errors for Class.forName
e.printStackTrace();
}finally{
//finally block used to close resources
try{
if(stmt!=null)
stmt.close();
}catch(SQLException se2){
}// nothing we can do
}//end try
System.out.println("Goodbye!");
String [] Nome;
Nome=new String[this.conta];
for(int k=0;k<this.conta;k++){
Nome[k]= Nomeperson[k];
}
return (Nome[1]);
}
Ora io voglio che ritorno non a un singolo valore ma a tutti i valori.
Ossia voglio passato al return Nome[0],Nome[1],Nome[2] fino a quanto arriva a conta-1. In modo tale che quando lo estendo questa classe in un altra classe mi posso prendere tutti i Nomi posizione per posizione
Si può fare e come?