• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Error compiling DataClientLocal

 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Aron that makes alot of since. Totally forgot about the implicit constructor call thanks alot Lisa
 
pie. tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic