This week's book giveaway is in the HTML Pages with CSS and JavaScript forum.
We're giving away four copies of Testing JavaScript Applications and have Lucas da Costa on-line!
See this thread for details.
Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Error compiling DataClientLocal

 
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
 
Curse your sudden but inevitable betrayal! And this tiny ad too!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic