GeeCON Prague 2014*
The moose likes Java in General and the fly likes Ljava/lang/String Error Pls Help... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Ljava/lang/String Error Pls Help..." Watch "Ljava/lang/String Error Pls Help..." New topic
Author

Ljava/lang/String Error Pls Help...

Jil Nautilus
Greenhorn

Joined: Jun 09, 2004
Posts: 13
Hi,
Im using a bean in a jsp to search a db and get results as a ResultSet.My bean is as below,

package MyBeans.CheckBeans;
import java.io.Serializable;
import java.sql.*;
import java.util.*;

public class SearchCustomer implements Serializable
{
Connection con;

public void connect()throws Exception
{
String Url = "jdbc:microsoft:sqlserver://192.169.100.1:1433;DatabaseName=SeaData";
String name = "myName";
String Pass = "myPassword";
String myDriver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";

Driver driver1 = (Driver)Class.forName(myDriver).newInstance();
con = DriverManager.getConnection(Url,name,Pass);

}

public void disconnect()throws Exception
{
if(con != null)
con.close();
}

public ResultSet searchByID(String ID)throws Exception
{
String custID = ID;
String query = "SELECT name,address FROM CustomerDetails WHERE "+
"customerID='"+custID+"'";

Statement stmt= con.createStatement();
ResultSet rs = stmt.executeQuery(query);

return rs;

}

public ResultSet searchByName(String name)throws Exception
{
String custName = name;
String query = "SELECT name,address FROM CustomerDetails WHERE "+
"Name LIKE '" +custName+ "%'";

Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);

return rs;

}

public ResultSet searchByAddress(String address)throws Exception
{
String custAddress = address;
String query = "SELECT name,address FROM CustomerDetails WHERE "+
"Address LIKE '"+custAddress+"%'";

Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(query);

return rs;
}

public int getSize(ResultSet rs)throws Exception
{
ResultSet res = rs;
int rsSize = -1;

// count the total records by iterating through the resultset
for (rsSize = 1; rs.next(); rsSize++);

rs.close();

return rsSize;
}

public ResultSet searchMeBy(String val,String cri)throws Exception
{
String searchVal = val;
String searchCri = cri;
ResultSet rs;

if(searchCri.compareToIgnoreCase("custID") == 0)
{
rs = searchByID(searchVal);
}

else if(searchCri.compareToIgnoreCase("custName") == 0)
{
rs = searchByName(searchVal);
}

else if(searchCri.compareToIgnoreCase("custAddress") == 0)
{
rs = searchByAddress(searchVal);
}

else
{
rs = null;
}

return rs;

}



}

Im trying to use searchMeBy to direct the user request in to the appropriate method as u can c.

all the other methods are working properly except searchMeBy and getSize methods.

When I try to use the searchMeBy method Ive got an error as

java.lang.NoSuchMethodError: MyBeans.CheckBeans.SearchCustomer.searchMeBy(Ljava/lang/String;Ljava/lang/String ;) Ljava/sql/ResultSet;

Then Ive removed the searchMeBy method and try to use getSize method but then got an error as

java.lang.NoSuchMethodError: MyBeans.CheckBeans.SearchCustomer.getSize(Ljava/sql/ResultSet ;) I

my IDE ---> is JCreator Pro 3.10.008
Java v ---> j2sdk1.4.2
OS ---> WinXP

Pls help me on this.
Thanx in advance for any help.
Best regs,
Jil

[ June 27, 2004: Message edited by: Ernest Friedman-Hill ]
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Getting an error message like this at runtime means that the class you compiled your code against is not the same one you're running against; these methods appear in your source code, but the .class file that the running application picks up is an older one that doesn't have these methods.

Check your runtime CLASSPATH, and search around for multiple copies of the searchCustomer class. Delete every copy you can find. Then recompile your app and try again.


[Jess in Action][AskingGoodQuestions]
Jil Nautilus
Greenhorn

Joined: Jun 09, 2004
Posts: 13
Thanx Ernest,
When I remove all those if statements in this method and write it like

public ResultSet searchMeBy(String val,String cri)throws Exception
{
String searchVal = val;
String searchCri = cri;
ResultSet rs=null;

return rs;

}
my jsp can identify this method.But when I put those if statements back its giving me the same error.There are no duplicate class files and if so there wont be something like I said above, isnt it?
By the way ,Thanx again for your support.
best regs,
Jil
 
GeeCON Prague 2014
 
subject: Ljava/lang/String Error Pls Help...