• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Error compiling DataClientLocal  RSS feed

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Aron that makes alot of since. Totally forgot about the implicit constructor call thanks alot Lisa
 
It will give me the powers of the gods. Not bad for a tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!