English 中文(简体)
org.postgresql.util.PSQLException: 本附录中未找到该栏的名称。
原标题:org.postgresql.util.PSQLException: The column name grupo was not found in this ResultSet. (DIFFERENT ERROR) [duplicate]
This question already has an answer here:
Closed 11 years ago.

Possible Duplicate:
org.postgresql.util.PSQLException: The column name usuario was not found in this ResultSet

我抱歉以同样的错误来问这个问题。 然而,情况有所不同。

因此,我为我们提供的数据库表如下:

usuario | grupo

admin   | 1
admin   | 1
erion   | 5

我的一套结果方法如下:

public Object objectFactory(ResultSet rs) {
        try {
            UsuariosGrupos usergroup = new UsuariosGrupos(rs.getString("usuario"), rs.getString("grupo"));
            return usergroup;
        } catch (SQLException e) {
            e.printStackTrace();
            // retorno do método
            return null;
        }
    }

错误出现在同一个行文上:

ugList.add((UsuariosGrupos) objectFactory(rs));

在我的清单方法中:

public List<UsuariosGrupos> select() {
    //Colecao List recebe null
    List<UsuariosGrupos> ugList = null;
    try {

        //Conecta no banco
        conn.conectar();
        //Prepara o preparedStatment
        stmt = (PreparedStatement) conn.getPreparedStatement("select * from usuarios_grupos");
        //Executa a instrucao SQL
        ResultSet rs = stmt.executeQuery();
        ugList = new ArrayList<UsuariosGrupos>();
        //Enquanto ouver resultSet
        while (rs.next()) {
            ugList.add((UsuariosGrupos) objectFactory(rs));
        }
        System.out.println("################################UsuariosGrupos OK################################");
    } catch (SQLException e) {
        System.out.println("################################UsuariosGrupos Falhou################################");
        e.printStackTrace();
    } finally {
        conn.desconectar();
    }
    return ugList;
}

这是我的乌苏里奥。 Grupos模型:

  public class UsuariosGrupos {

    private String usuario;
    private String grupo;

    public UsuariosGrupos() {
    }

    public UsuariosGrupos(String usuario, String grupo) {
        this.usuario = usuario;
        this.grupo = grupo;
    }

   public String getGrupo() {
        return grupo;
    }

    public void setGrupo(String grupo) {
        this.grupo = grupo;
    }

    public String getUsuario() {
        return usuario;
    }

    public void setUsuario(String usuario) {
        this.usuario = usuario;
    }


}

我拿不到。 我的结果与我的数据库相匹配,但我正在发现错误。 Same letter-casing. 是否有任何人知道我做了什么错误?

我的乌阿里奥斯-戈鲁戈斯的乌阿里奥和贪.是一个主要的综合关键。 你们是否认为与错误有任何关系? 感谢!

问题回答

下表所示为:

Usuarios | Grupos

admin        2
admin        3

Then your ResultSet should be rs.getString("Grupos");

我要问,ResultSetMetaData检查一下它认为它实际上可以提供给你什么一栏。

此外,在提出询问时也明确无误。 Don t use SlectT *,但指定了明确的栏目名称(在这种情况下:如果确实没有栏目grupos,你会提前发现错误)。





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签