我遇到了一个例外,但找不到原因。
我得到的例外是:
java.lang.IllegalAccessError:尝试访问方法Connected.getData(Ljava / lang / String;)Ljava / sql / ResultSet; 从B类
该方法是公开的。
public class B
{
public void myMethod()
{
Connected conn = new Connected(); // create a connected class in order to connect to The DB
ResultSet rs = null; // create a result set to get the query result
rs = conn.getData(sql); // do sql query
}
}
public class Connected
{
public ResultSet getData(String sql)
{
ResultSet rs = null;
try
{
prepareConnection();
stmt = conn.createStatement();
stmt.execute(sql);
rs = stmt.getResultSet();
}
catch (SQLException E)
{
System.out.println("Content.getData Error");
E.printStackTrace();
}
return rs;
}
我正在使用Tomcat 5.5.12和JAVA 1.6