Postgres JDBC driver not returning the exact error line number as shown in PGAdmin. When I run the below program :
import java.sql.*;
public class Test {
public static void main(String[] args) {
String query = "SELECT table_name, table_type\n" +
" FROM information_schema.tabls\n" +
" WHERE table_schema='public'\n" +
" AND table_type in ('BASE TABLE','VIEW') ORDER BY table_type, table_name;";
try (Connection connection = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres", "postgres", "postgres")) {
System.out.println("Connected to PostgreSQL database!");
Statement statement = connection.createStatement();
ResultSet resultSet = statement.executeQuery(query);
while (resultSet.next()) {
System.out.printf("%-30.30s %-30.30s%n", resultSet.getString("table_name"), resultSet.getString("table_type"));
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
I am getting the following error :
org.postgresql.util.PSQLException: ERROR: relation "information_schema.tabls" does not exist
Position: 38
But when I run the same query on pgadmin4, I receive the following error :
ERROR: relation "information_schema.tabls" does not exist
LINE 2: FROM information_schema.tabls
^
SQL state: 42P01
Character: 38
I want the line number in java program as well. How can I get it?