static/non-static issues between two non-static methods of two diff classes
717913Apr 25 2010 — edited Apr 25 2010I use Jdeveloper to develop my application on Widow XP.
I have two classes: one is called genPricingClass and the other is ycRateDb Class. The genPricingClass has many non-static methods and one of them is the non-static getYCrates() method. (Please see below for partial code of two methods)
The ycRateDb class has three methods and all of them are non-static method.
The ycRateDb class compiles without compilation errors. When I compile genPricingClass I get the following compilation error message.
C:\oracle\mywork\genPricingObjectArrayYcRateMeth\genPricing\src\genPricingPackage\genPricingClass.java
Error(657,21): cannot make a static reference to non-static method ycRateDB(int, int, int, int, int, int, java.lang.String, java.lang.String, boolean, genPricingPackage.dbCon)
It highlights the call statement ycRateDb.ycRateDB( ?????) in the getYCrates() method of genPricingClass being the problem.
Any one have any idea why it complaints that getYCrates() method is a static method although it is not declared as static method?
******************************************
public void getYCrates() throws SQLException, Exception {
dbCon dbcon = new dbCon();
dbcon.gp = gp;
dbcon.main(dbcon); // this method is non-static method in a different class.
boolean isFirstTime = true;
for (i = 1; i <= numCurrMat; i++) {
ycRate[i] =
ycRateDb.ycRateDB(ycMonth, ycDay, ycYear, dueDateX[0],
dueDateX[1][i], dueDateX[2][i], "B",
gpBean.ycStartPoint, isFirstTime, dbcon);
ycRate[i] = UtilCalcs.dRateConvert(ycRate[i], 2, gpBean.pmtsPerYr);
}
if (i ==1) isFirstTime = false;
}
}
******************************************
// Programmer: Kaverappa Prabhakar 2009
package genPricingPackage;
import java.io.CharArrayWriter;
import java.io.PrintWriter;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;
public class ycRateDb {
public static String maxMaturityDate;
public ycRateDb() {
}
public void setMaxMaturityDate(String curveTable, String curveDateColumn, String curveDate,
String curveType, dbCon dbcon) throws SQLException {
Here there is code pertaining to:
SQL statement, Statement, CreateStatement, executerQuery, resultSet and exception handler
}
}
public char getQuoteHour(String curveType){
char quoteHour = 'C';
switch (curveType.charAt(0)) {
case 'A':
quoteHour = 'A';
break;
case 'B':
quoteHour = 'C';
break;
case 'G':
quoteHour = 'G';
break;
case 'S': // SLGS CURVE
quoteHour = 'S';
break;
default:
if (curveType.equals("")) // case '' - Regular (Nominal Bid Curve)
quoteHour = 'C';
else{
// genPricingClass.setDisplayPage("error.jsp");
// genPricingClass.setErrorText("Invalid Curve Type: " + curveType + ". Call us
at 202-691- to report this problem.");
}
break;
}
return quoteHour;
}
// Programmer: K. Prabhakar
public double ycRateDB(int crvMon, int crvDay, int crvYr,
int matMon, int matDay, int matYr,
String crvType,
String ycStart, boolean isFirstTime, dbCon dbcon) throws
Here there is code pertaining to:
SQL statement, Statement, CreateStatement, executerQuery, resultSet and exception handler
return ycRateDb;
} // end of ycRateDb method