-2

My problem is that intellij raise an error that unable to resolve table user.

Table is created in database it can be seen in database in Intellij but it looks like compiler doesn't have an access to it. Did someone have similiar problem?

enter image description here

public void getUser(String user) {
        connect();
        String SQL = "SELECT users , password  FROM users WHERE users = ?";
        try {
            pstmt = connection.prepareStatement(SQL);
            pstmt.setString(1, user);
            pstmt.executeUpdate();
            ResultSet rs = pstmt.executeQuery(SQL);
            System.out.println(rs.getString("password"));
        } catch (SQLException ex) {
            System.out.println(ex.getMessage());
        }
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61

2 Answers2

0

If you can confirm that the table exists and you connect to the right database, the error message might be misleading. This can be caused by incorrect database/dialect settings as well as other IntelliJ db connection settings.

Zegarek
  • 6,424
  • 1
  • 13
  • 24
  • Yes im connected to right db cause when i insert new data into table users it appears there , dialect is set to MariaDB global and for project. Problem appears when im trying query a table in method getUser, function doesnt work. – Rafal Graczykowski Nov 28 '21 at 20:58
  • @RafalGraczykowski Make sure you change the dialect on global and project but also on [directory level](https://intellij-support.jetbrains.com/hc/en-us/community/posts/360007017959/comments/360001311360) to the right one. Once you do, make sure you [refresh the connection](https://stackoverflow.com/a/68460687/5298879). You should also edit your question to state what you are really using: MariaDB and PostgreSQL are two different RDBMS with different dialects. Your question uses `postgresql` tag, `mariadb` is the tag you should be using if that's the one you're working with. – Zegarek Nov 29 '21 at 06:50
-1

Press "choose schema" link :)