I want to fetch complete data from the database's table through RMI. I used the array method in the Java interface and I have implemented that method in implementation class. My intention is to take the data in the array via implementation and show it via JTable
on the client side. I have created a one-column table in the database. I have to get that whole data from that table to the client side.
I have attached the coding that I did. I have commented the errors in the code section that I got.
interface
public interface Interface extends Remote {
public static String[] getArray() throws Remote Exception; // Here it shows missing method
// body or declare abstract
}
Implementation
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.
}
}