• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot see table after successful JDBC connect to PostgreSQL 9.3 database on Windows XP

 
Casey Kemp
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.sql.*;
import java.util.*;

public class JdbcPostgresqlConnection {
public static void main(String[] args) {

try {
Class.forName("org.postgresql.Driver");
Connection dbmsConn = null;
String dbURL3 = "jdbc:postgresql://localhost:5432/testDBMS";
Properties parameters = new Properties();
parameters.put("user", "pgmrHere");
parameters.put("password", "111111");
dbmsConn = DriverManager.getConnection(dbURL3, parameters);
if (dbmsConn != null) { System.out.println("Connected to database"); }

String strSqlQuery =
"SELECT * " +
"FROM tstSchema.tblOne " +
"WHERE " +
"colOne = " + 1;

// EXECUTE SQL QUERY
Statement stmtSqlStatement = dbmsConn.createStatement();
ResultSet recordSet = stmtSqlStatement.executeQuery(strSqlQuery);


}
catch (Exception ex) { ex.toString(); }
}
}


The error I get is the table does not exist.
 
Dave Tolls
Ranch Hand
Posts: 2091
15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That sort of implies that the table doesn't exist.

Connect to the db using that connection string and user/password, and copy that query and run it.

Could be a simple typo, or access privileges for the user on that schema.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic