日期:2014-05-17  浏览次数:20671 次

真不明白这是什么问题,我是菜鸟,高手们应该知道的
<%@page pageEncoding="GB18030"%>
<%@page import="java.sql.*,java.io.*,com.bjsxt.bbs.*,java.util.*"%>
<%!
private void tree(Set<Article> articles,Connection conn,int id,int grade){
String sql = "select * from article where pid = " + id;
Statement stmt = DB.createStmt(conn);
ResultSet rs = DB.executeQuery(stmt,sql);
try{
while(rs.next()){
Article a = new Article();
a.setId(rs.getInt("id"));
a.setPid(rs.getInt("pid"));
a.setTitle(rs.getString("title"));
a.setLeaf(rs.getInt("isleaf") == 0 ? true : false);
a.setPdate(rs.getTimestamp("padate"));
a.setGrade(grade);
articles.add(a);
if(!a.isLeaf()){
tree(articles,conn,id,grade +1);
}
}
}catch(SQLException e){
e.printStackTrace();
}
}
%>

这是我的代码,红色字体就是出问题的地方,问题的提示是:
The method createStmt(Connection) in the type DB is not applicable for the arguments (Connection)

这是马士兵里面的一段代码,我检查了代码应该是没有敲错的,为什么我就出这个问题呢。。

------解决方案--------------------
import com.sun.corba.se.pept.transport.Connection;//DB类里引入的是这个Connection

public static Statement createStmt(Connection conn){
}


JSP 里用的是java.sql.Connection
<%@page import="java.sql.*,java.io.*,com.bjsxt.bbs.*,java.util.*"%>
知道错在哪了吧