I am trying to query a NonStop SQL/MX database using JDBC. I have the correct driver and I manage to connect to the database and to initialize a statement with the following lines of code (which i found here):
Class.forName("com.tandem.t4jdbc.SQLMXDriver");
Connection con = DriverManager.getConnection(url, user, password);
Statement stmt = con.createStatement();
However, I fail to execute the query...
ResultSet rs = stmt.executeQuery("SELECT * FROM Table1");
... because of some inexistent catalog NONSTOP_SYSTEM_NSK
. What does that mean? I never have to specify any catalog when viewing the same database in a GUI (e.g., DB Visualizer).
The resulting stack trace looks something like this:
java.sql.SQLException: *** ERROR[1002] Catalog NONSTOP_SYSTEM_NSK does
not exist or has not been registered on node \NSK01.
at com.tandem.t4jdbc.SQLMXMessages.throwSQLException(SQLMXMessages.java:71)
at com.tandem.t4jdbc.InterfaceStatement.executeDirect(InterfaceStatement.java:545)
at com.tandem.t4jdbc.SQLMXStatement.executeQuery(SQLMXStatement.java:226)
If you already have a working Connection con
, you can set the catalog using con.setCatalog()
. In general, you access a database table in a given catalog and schema as follows:
ResultSet rs = stmt.executeQuery("SELECT * FROM <CATALOG>.<SCHEMA>.<TABLE>");