Voglio recuperare i dati completi dal database della tabella attraverso RMI. Ho usato il metodo di matrice nell'interfaccia Java e ho implementato il metodo nella classe di implementazione. La mia intenzione è di prendere i dati nella matrice, tramite la realizzazione e mostra la via JTable
sul lato client. Ho creato una tabella con una colonna nel database. Devo prendere quel complesso di dati dalla tabella a lato client.
Ho allegato la codifica che ho fatto. Ho commentato gli errori nella sezione di codice che ho ottenuto.
interfaccia
public interface Interface extends Remote {
public static String[] getArray() throws Remote Exception; // Here it shows missing method
// body or declare abstract
}
Attuazione
public class TheImplementation extends UnicastRemoteObject implements Interface{
public TheImplementation()throws Remote Exception{
super();
}
private static final long serialVersionUID = -3763231206310559L;
Connection con;
PreparedStatement pst;
ResultSet rst;
public static String[] getArray() throws RemoteException{
String fruitdetails = null;
try {
Connection connection=ConnectionProvider.getConnection();
Statement st=connection.createStatement();
ResultSet rs=st.executeQuery("select *from details");
while(rs.next()) {
fruitdetails= rs.getString("fruit");
String tbData[]={fruitdetails};
}
}
catch (SQLException e) {
JOptionPane.showMessageDialog(null, e);
}
return tbData;// Here it shows error. Cannot find symbol.
// I tried to declare array at top. But, It didn't work.
}
}