Java MySQL部署错误(UnsupportedOperationException)

时间:2012-12-10 22:17:50

标签: java sql tomcat netbeans wicket

我正在研究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}"/>

0 个答案:

没有答案