This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Heres the code: Interface package suncertify.db; import java.io.*; import java.util.*; import java.rmi.*; public interface DataClient extends Remote { public FieldInfo [] getFieldInfo()throws RemoteException; public DataInfo getRecord(int recNum)throws DatabaseException, RemoteException; public DataInfo find(String toMatch)throws DatabaseException, RemoteException; public void add(String [] newData)throws DatabaseException, RemoteException; public void modify(DataInfo newData)throws DatabaseException, RemoteException; public void delete(DataInfo toDelete)throws DatabaseException, RemoteException; public void close() throws RemoteException; public void lock(int record)throws IOException, RemoteException; public void unlock(int record)throws RemoteException; public DataInfo[] criteriaFind(String criteria) throws DatabaseException, RemoteException; public String[] getComboValues(int fieldNum) throws DatabaseException, RemoteException; public int getMatchCount(String matchCount) throws DatabaseException,RemoteException; } Heres the code DataClientLocal class package suncertify.db; import java.io.*; import java.util.*; public class DataClientLocal extends Data implements DataClient {
public DataClientLocal(String dbname){ try { Data dbInstance = new Data(dbname); } catch(Exception ex) { System.out.println("Database connection failed"); } } }
I have 3 methods I defined in the Data class but I dont understand why it is looking for Data()???
C:\scjd\starting\suncertify\db\DataClientLocal.java:9: No constructor matching Data() found in class suncertify.db.Data. public DataClientLocal(String dbname){ ^ 1 error Process completed with exit code 1 Thanks Lisa
Lisa Foster
Ranch Hand
Joined: Feb 28, 2001
Posts: 116
posted
0
I have added a empty constructor to Data Class and it now compiles fine any reason why I need a public Data(){} in my Data Class to get my above DataClientLocal to compile? Thanks Lisa
Aron J. Skantz
Greenhorn
Joined: Oct 12, 2000
Posts: 26
posted
0
Hi Lisa! Yes, there is a good reason to why you need a empty constructor in the Data class. If you extend a class and add a constructor to your new sub class as this: public DataClientLocal(String dbname){ {some code} } then what really will be performed is this: public DataClientLocal(String dbname){ super(); {some code} } Since super() tries to call an empty constuctor in Data and there isnt any, then the compilation will fail. To solve this, add an explicit super(...) _on the first line of the new constuctor_ that matches one of the constructors in Data. Regards \Aron [This message has been edited by Aron J. Skantz (edited March 16, 2001).]
Lisa Foster
Ranch Hand
Joined: Feb 28, 2001
Posts: 116
posted
0
Thanks Aron that makes alot of since. Totally forgot about the implicit constructor call thanks alot Lisa
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.