Chcem, aby priniesla úplné údaje z databázy tabuľka prostredníctvom RMI. Použil som rad metóda v rozhraní Java a implementovali sme, že metóda implementácie v triede. Mojím zámerom je, aby údaje v poli, cez implementáciu a ukázať, že cez JTable
na strane klienta. Vytvoril som jeden stĺpec tabuľky v databáze. Musím si to celé údaje z tabuľky na strane klienta.
Mám pripojený kódovanie, že som to urobil. Som poznamenal, chyby v sekcii kódu, ktorý som dostal.
rozhranie
public interface Interface extends Remote {
public static String[] getArray() throws Remote Exception; // Here it shows missing method
// body or declare abstract
}
Realizácia
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.
}
}