I'm trying to connect Selenium with Postgres and the following error is shown:
FAILED: selectQuery org.postgresql.util.PSQLException: ERROR: relation "login" does not exist
My code is below:
package Posgress; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; import org.testng.annotations.Test; @Test public class PosgressTest { public static void selectQuery() throws SQLException, ClassNotFoundException { //Load MySQL JDBC Driver Class.forName("org.postgresql.Driver"); Connection connection = DriverManager .getConnection("jdbc:postgresql://localhost:5432/DIC","postgres", "root"); Statement st = connection.createStatement(); System.out.println("Connection"); String selectquery = "Select * from Login"; System.out.println("Connection1"); // Executing the SQL Query and store the results in ResultSet ResultSet rs = st.executeQuery(selectquery); // While loop to iterate through all data and print results while (rs.next()) { System.out.println(rs.getString("username")); System.out.println(rs.getString("password")); } // Closing DB Connection connection.close(); } }
I have a table 'Login inside schema "DICschema'. I wrote select query like this also "Select * from DICschema.Login" then also same error