0

我正在从事 Wicket 项目并遇到问题。这是我的一段代码:

private static String select_fkey = "SELECT fullname FROM PROFILE"; 
private static String select_table = "SELECT * FROM MESSAGE ORDER BY id DESC"; 



try{

        String query = select_table;
        Statement statement = this.connection.createStatement();
        ResultSet result = statement.executeQuery(query);

        while(result.next()){

            this.list.add(getMessage(result));
        }
    }
    catch(SQLException e){

        throw new UnsupportedOperationException(e.getMessage());
    }

private Message getMessage(ResultSet rs) throws SQLException{

        Statement sender_statement = this.connection.createStatement();
        ResultSet sender_result = sender_statement.executeQuery(select_fkey + " WHERE (id = " + rs.getInt("sender_id") + ")");

        return new Message(rs.getInt("id"), 
                           rs.getString("content"),  
                           rs.getInt("sender_id"), 
                           rs.getInt("receiver_id"),
                           rs.getString("datetime"),
                           sender_result.getString("fullname"));
    }

该表MESSAGE有这 5 个字段,我想定义一个Message对象,该对象还存储发送它的人的姓名。

问题是,我实际上不知道如何从相关表中获取信息,所以我尝试了这种方式,但它捕获了UnsupportedOperationException(根据 Apache Tomcat 服务器日志)并给出了部署错误。有没有合适的方法来做这个操作?或者,我做错了什么?

顺便说一句,它显然是使用这个函数而不是上面的函数运行的:

private Message getMessage(ResultSet rs) throws SQLException{

            return new Message(rs.getInt("id"), 
                               rs.getString("content"),  
                               rs.getInt("sender_id"), 
                               rs.getInt("receiver_id"),
                               rs.getString("datetime"));
        }

错误信息:

nbproject/build-impl.xml:1027: The module has not been deployed.
See the server log for details.

build-impl.xml:1027 说:

<nbdeploy clientUrlPart="${client.urlPart}" debugmode="true" forceRedeploy="${forceRedeploy}"/>
4

0 回答 0