java/SQL ORA-00942 table or view does not exist

时间:2015-05-24 20:57:42

标签: java sql oracle

I have been having a problem with the sql. I have been trying to build a login system that will read a username and password from an oracle DB. When I connect and carry out the command

String sql="select * from tutilizadores where username= ? and password= ?";

I get the error message ORA-00942. The table has been created under sys. I am confused.

Here is the code that refers to the problem:

        String sql="select * from tutilizadores where username= ? and password= ?";
        PreparedStatement pst = conn.prepareStatement(sql);
        pst.setString(1, USERNAME.getText());
        pst.setString(2, PASSWORD.getText());
        rs=(OracleResultSet)pst.executeQuery();
        if (rs.next()){
        JOptionPane.showMessageDialog(null, "O username e password estavam bem");
        //Fecha a janela
        //close();

        //nova janela-Tutilizadores
        Tutilizadores c = new Tutilizadores();
        c.setVisible(true);
        }

Thanks a lot.

1 个答案:

答案 0 :(得分:0)

The number of issues is usually limited to those few options:

  1. You are logged in to the wrong database
  2. Logged in using the wrong username
  3. You are required to qualify the table name with the schema name as in schema.tutilizadores. If not sure, then consider schema as the username used to create the table.
  4. Somehow you managed to have the table name wrong. Possibly table is case sensitive: if qualified inside double quotes, case will be literally matched, otherwise oracle will assume uppercase.

For verifying what the issue is, consider executing and providing the output of following SQL:

SELECT table_name, owner
FROM dba_tables
WHERE lower(table_name) = 'tutilizadores'
相关问题