Why does running a query return 'table_oid' under messages and nothing under Data Output - postgresql

Running any sort of query on pgAdmin 4 just returns a 'table_oid' under messages.
I am able to get the necessary data when running the query from the command line, for example
SELECT ST_MakePolygon(ST_GeomFromText('LINESTRING(75.15 29.53,77 29,77.6 29.5, 75.15 29.53)'));
I understand that table_oid refers to the object id of the table, but I have no idea how to access it.
Pardon me please if it is a simple question, but I am unable to find any resources online
Expected:
010300000001000000040000009A99999999C9524048E17A14AE873D4000000000004053400000000000003D4066666666666653400000000000803D409A99999999C9524048E17A14AE873D40
Actual:
table_oid

From pgAdmin 4 project tracker:
Temporary solution until next release and tested in my ubuntu 18.04 machine:
Replace these two 2 files:
/usr/share/pgadmin4/web/pgadmin/tools/sqleditor/__init_*_py
/usr/share/pgadmin4/web/pgadmin/tools/sqleditor/command.py
Link to files:
__init_*_.py
command.py
Note:
The first file's name is __init_*_py, without the *.

Try Squirrel SQL - Universal SQL Client. It's an extremely useful SQL client. I use it to access SQL Server, PostgreSQL, MySQL, Access. It's not as good looking as pgAdmin4.
Install JAVA first, if not already installed.
Install Squirrel SQL.
Download the latest PostgreSQL JDBC driver, e.g. postgresql-42.2.6.jar, and put it into a convenient location.
Open/Start Squirrel.
Click the Drivers Tab and scroll down to PostgreSQL. Double click PostgreSQL. A "Change Driver: PostgreSQL" dialog box/window will open.
Click the Extra Class Path tab and click the Add button. Navigate to and choose the PostgreSQL JDBC Driver that was downloaded in step 3. above.
Click the List Drivers button, "org.postgresql.Driver" should appear in the Class Name drop down box.
Click OK.
Setup PostgreSQL JDBC Driver
The driver should now be setup.
Click the Aliases tab to setup a connection to your database. See my example screenshots.
Setup Database Connection

Related

Databases in psql Don't Show up in PgAdmin4

I installed Postgres
and followed the instruction. I create a database and logged in by the master password but I don't find the database even the + mark is not shown in the servers. can anyone help, please?
Unlike in pgAdmin3, with pgAdmin4,here you have to manually connect to a running postgres server andyou already have your specific database (DB) created.
So to set the stage, make sure you have the postgres server is running, and that you have created that DB already too.
Notice (in the image) that I CREATE database XYZ and GRANT all privileges to default user postgres. (Note; to work properly with pgAdmin4, you have to create a user called postgres in order to be able to connect with and log in to pgAdmin4.)
Then here are some quick steps to follow:
When within pgAdmin4, right-click the Servers option and select create.
Note:
In the image you'll see (1) next to "Servers" because I have done this process already. Kindly ignore that).
Select "server group" if you have many servers that you want to better manage. For most basic use cases, go ahead and select "server" (like I did).
For either option you select above, you'll get a pop-box to complete the "connection process". I selected "server" which is appropriate for your use case (see image below).
Note:
"name" field is required
As you can see already, enter a name (I went with "postgres" since it's what I was used to by default in pgAdmin3, but you can enter any name).
Notice the "connect now" checkbox is checked by default so as soon as the process is successful, your DB should display in the sidemenu. (This is a key to confirm that you entered the right info). But you can always uncheck this, to connect later.
Now, click connection tab and you see the image below.
The key fields to fill here, to keep it simple, are host name/address and password. Remember to save after entering your info.
Note:
If on connecting to local machine, localhost or http://127.0.0.1 should do. (I did "localhost")
If connecting to a DB instance in the cloud e.g. AWS, enter the endpoint in the host space. Here's more from AWS
A lot of the other fields have the default settings used when installing postgres and pgAdmin.
If you followed the steps above properly, then you should see something like this after you save.
Here's a good guide from the pgAdmin documentation
In case you created your database as template CREATE DATABASE ... IS_TEMPLATE =true, then the database is considered as "system object" and is not shown in the list if PgAdmin4 option "Show system objects?" is set to false.
Try menu File -> Preferences, in the tree find Browser -> Display, and the option is at the bottom.
Another option is to remove the template option:
ALTER DATABASE xxx IS_TEMPLATE = false
and then you will see your database without changing PgAdmin preferences.
I followed the introductory advice from #MwamiTovi but I still did not have an option to create a server as he noted. However, I was able to get my databases to appear by clicking menu option Object -> Register -> Server and type in the information (hostname/address, port) from my associated psql setup.
This was using PG Admin 4.19 on macOS Big Sur.

Datastage Oracle Importing Table

I have a error when i use datastage connect to Oracle and import the table definition. Below is the detailed situation.
enviroment:
OS:AIX6.1,64bit,power6 processor, LANG=en_US
Data Stage Version:8.5
Installation profile
three tiers install on same machine, repository use DB2 (default).
Oracle Client 11.2 (64bit) also install on this machine, I can use SQLPLUS connect to Oracle server (11.2, 64bit, AL32UTF8) on another machine.
"dsenv" setting
add "/oracle/product/11.2.0-64/lib" to the "LIBPATH"
add "export TNS_ADMIN=/oracle/product/11.2.0-64/network/admin"
Problem
1. I use Oracle Connector(parallel) create a Link, then use this Link import Metadata, when i press Test connection, there is a dialog with "The OCI function OraOCIEnvNlsCreate:OCI_UTF16ID returned status -1. Error code: NULL, Error message: NULL" popup, and the connection failed.
I use Oracle Enterprise(parallel) create a Link, then use it import Metadata, when i click Ellipsis button list all the tables in target database, there is a dialog with "cannot get list of table names from database" popup, after I click OK on this dialog, the detail error message popup.
12:37:21(002) Unable to access database oracleLibrary orchoracle could not be loaded; Could not load "orchoracle": 
0509-022 Cannot load module /opt/IBM/InformationServer/Server/DSComponents/bin/orchoracle.o.
0509-150 Dependent module /opt/IBM/InformationServer/Server/DSComponents/bin/libclntsh.so could not be loaded.
0509-103 The module has an invalid magic number.
0509-022 Cannot load module /opt/IBM/InformationServer/Server/DSComponents/bin/orchoracle.o.
0509-150 Dependent module /opt/IBM/InformationServer/Server/DSComponents/bin/orchoracle.o could not be loaded.
from the message I found the DS search some files in DSCompoments/bin, but these files are in the oracle bin directory. I can't find the error in dsenv file, so i copied these files into DSComponents/bin, this time the error message changed to "OCI_ERROR: Bad Oracle environment".
I am not sure which enviroment variable I missed, please tell me.
I use Oracle OCI(Server) create a Link and import a table, it works fine.
So, my question is why I can't use the Oracle Connector and Oracle Enterprise to connect the Oracle. Thanks.
Yes the PATH variable needs to be set to $ORACLE_HOME/bin. Adding this variable to the dsenv file and recycling all services fixed the Oracle COnnector issue for us. It is required to be added to the dsenv file and recycling ASBNode and datastage is also required. Here are the directives needed in the dsenv file to use Oracle Connector :(eg is from our system AIX 6.1 , datastage 8.5 connecting to Oracle 11g Enterprise)
We also added the following :
TNS_ADMIN=/opt/oracle/product/11.1.0/client_1/network/admin; export TNS_ADMIN

pgadmin4 query tool always comes back not connected

Q: How can I diagnose and correct problems with the Query tool connection.
Using pgAdmin4 1.0-rc1 to connect to a local host "PostgreSQL 9.5.3, compiled by Visual C++ build 18..."
I can connect and drill down to my schema. I use the context menu to select 'Query tool'. The editor shows the correct database#host:port in the editor header bar.
When I execute a simple query, or any query
select 1 as first;
I get the message
"Not conencted to the server or the connection to the server has been closed.
instead of the expected results.
The editor alwa
This issue has been resolved now,
Upgrade pgAdmin4 to version 1.3. https://www.pgadmin.org/download/
All you have to do is wrap the schema, table, column names with double quotation marks in every sentence.

what driver to use when connecting to Oracle 10 with IBM RAD / Eclipse DTP?

I'm using IBM RAD 7.5.5 (which is basically eclipse 3.4 (ganymede) + plugins).
I'm trying to create a connection to Oracle 10 using the "Data Source Explorer" view.
When I create a new connection for Oracle, there are three "driver" options:
"Oracle 10 - Oracle OCI Driver Default"
"Oracle 10 - Oracle Thin Driver Default"
"Oracle 10 - Other Driver Default"
1 & 2 don't work for me because I need to connect to the db using a "Service Name", not an "SID". The dialog box does not give me the option of specifying a Service Name, and it does not allow me to manually specify the connection URL. (Service Name has a different URL syntax, uses a '\' instead of a ':", like so ...
With SID: jdbc:oracle:oci:#localhost:1521:the_sid
With Service Name: jdbc:oracle:oci:#localhost:1521\the_sevrice_name
So ... I want to use option #3 which allows me to specify the URL manually. The problem is I add the driver file ojdbc14.jar to the JAR list, but it keeps telling me "Invalid JAR definition; driver list not defined".
Can anyone help? I'm really stuck on this. :(
Thanks,
Rob
FYI, at long last I found a solution to my problem.
While I was never able to establish the connection with the "Service Name" using Eclipse/DTP "Data Source Explorer", I was able to establish the connection with "Service Name" using SQL Developer. Once connected with SQL Developer, I did a ...
select sys_context ('userenv','instance_name') from dual;
... to determine the database's SID.
With the SID I was able to connect with option #1 and the driver contained in ojdbc14.jar.
Thanks all, Rob
If you are stuck with a more recent version of Oracle (e.g. Oracle 12) on a recent RAD or Eclipse installation you should try to do the following:
Download the Oracle 12 ojdbc7.jar. If you are on java6 you should download ojdbc6.jar
Create a new connection
Select Oracle 12 - Other Driver Default
Press the [...] dot, remove the default ojdbc6.jar and add the jar you downloaded before
Insert database name, the url (as jdbc:oracle:thin:#server:port/service ), the username and password, check the save password box if you wish.
Click Next and then Finish. Eclipse will try to test the connection, if the driver is still giving you problems then you need to force Eclipse (or RAD) to save the connection and you can fix it later.
Now you can fix the driver properties. This step is necessary to eventually be able to call the thin client in the jar.
In the database connection list choose the new connection you just created and press right button > properties
Choose Driver Properties
Click on the delta icon (the small triangle) near the Drivers combo box.
Open the Properties tab, then edit the properties as follow:
Catalog - USER
connection url - jdbc:oracle:thin:#server:port/service
Database Name - db
Driver Class - oracle.jdbc.driver.OracleDriver
Now your connection test should be succesful.

Oracle SQL Developer and PostgreSQL

I'm trying to connect to a PostgreSQL 9.1 database using Oracle SQL Developer 3.0.04, but I'm not having any success so far.
First, if I add a third party driver on preferences, when adding a new connection there's no tab for PostgreSQL (it works fine for MySQL though). I'm using a JDBC4 version 9.1 driver, but I tried a JDBC3 of the same version and still get the same thing.
Second, there's nothing like manual configuration tab when adding a new connection. The closest is the Advanced option on Oracle tab, where I can provide a custom URL, but it fails because complains about the selected Driver (of course).
Finally, I got connected importing a connection from an XML file (contents below), but it displays only my schemas and doesn't show my tables inside them.
So, my question is: does Orable SQL Developer support PostgreSQL connections? Is there any other way to have my tables being displayed in the ObjectViewer?
<?xml version = '1.0' encoding = 'UTF-8'?>
<References xmlns="http://xmlns.oracle.com/adf/jndi">
<Reference name="Lumea" className="oracle.jdeveloper.db.adapter.DatabaseProvider" credentialStoreKey="Lumea" xmlns="">
<Factory className="oracle.jdeveloper.db.adapter.DatabaseProviderFactory"/>
<RefAddresses>
<StringRefAddr addrType="user">
<Contents>lumea</Contents>
</StringRefAddr>
<StringRefAddr addrType="subtype">
<Contents>thirdParty</Contents>
</StringRefAddr>
<StringRefAddr addrType="customUrl">
<Contents>jdbc:postgresql://localhost:5432/versates</Contents>
</StringRefAddr>
<StringRefAddr addrType="SavePassword">
<Contents>true</Contents>
</StringRefAddr>
<StringRefAddr addrType="password">
<Contents>myencryptedpass</Contents>
</StringRefAddr>
<StringRefAddr addrType="driver">
<Contents>org.postgresql.Driver</Contents>
</StringRefAddr>
<StringRefAddr addrType="DeployPassword">
<Contents>true</Contents>
</StringRefAddr>
</RefAddresses>
</Reference>
</References>
Oracle SQL Developer 4.0.1.14 surely does support connections to PostgreSQL.
download JDBC driver for Postgres (http://jdbc.postgresql.org/download.html)
in SQL Developer go to Tools → Preferences, Database → Third Party JDBC Drivers and add the jar file (see http://www.oracle.com/technetwork/products/migration/jdbc-migration-1923524.html for step by step example)
now just make a new Database Connection and instead of Oracle, select PostgreSQL tab
Edit:
If you have different user name and database name, one should specify in hostname: hostname/database? (do not forget ?) or hostname:port/database?.
(thanks to #kinkajou and #Kloe2378231; more details on https://stackoverflow.com/a/28671213/565525).
I've just downloaded SQL Developer 4.0 for OS X (10.9), it just got out of beta. I also downloaded the latest Postgres JDBC jar. On a lark I decided to install it (same method as other third party db drivers in SQL Dev), and it accepted it. Whenever I click "new connection", there is a tab now for Postgres... and clicking it shows a panel that asks for the database connection details.
The answer to this question has changed, whether or not it is supported, it seems to work. There is a "choose database" button, that if clicked, gives you a dropdown list filled with available postgres databases. You create the connection, open it, and it lists the schemas in that database. Most postgres commands seem to work, though no psql commands (\list, etc).
Those who need a single tool to connect to multiple database engines can now use SQL Developer.
Oracle SQL Developer doesn't support connections to PostgreSQL. Use pgAdmin to connect to PostgreSQL instead, you can get it from the following URL
http://www.pgadmin.org/download/windows.php
I managed to connect to postgres with SQL Developer.
I downloaded postgres jdbc driver and saved it in a folder.
I run SQL Developer -> Tools -> Preferences -> Search -> JDBC
I defined postgres jdbc driver for the Database and Data Modeler (optional).
This is the trick.
When creating new connection define Hostname like localhost/crm? where crm is the database name. Test the connection, works fine.
If there is no database with the same name as the username, then clicking "Choose Database" will fail with an error like "Status : Failure -FATAL: database "your_username" does not exist"
To work around this, put 5432/database_name? in the Port field, where 5432 is the port of your Postgres instance and database_name is the name of at an existing database that your_username has access to. Then click "Choose Database" again and it should work. Now you can choose the database you want and remove the extra /database_name? from the Port field.
I think this question needs an updated answer, because both PostgreSQL and SQLDeveloper have been updated several times since it was originally asked.
I've got a PostgreSQL instance running in Azure, with SSLMODE=Require.
While I've been using DBeaverCE to access that instance and generate an ER Diagram, I've gotten really familiar with SQLDeveloper, which is now at v19.4.
The instructions about downloading the latest PostgreSQL JDBC driver and where to place it are correct. What has changed, though, is where to configure your DB access.
You'll find a file $HOME/.sqldeveloper/system19.4.0.354.1759/o.jdeveloper.db.connection.19.3.0.354.1759/connections.json:
{
"connections": [
{
"name": "connection-name-goes-here",
"type": "jdbc",
"info": {
"customUrl": "jdbc:postgresql://your-postgresql-host:5432/DBNAME?sslmode=require",
"hostname": "your-postgresql-host",
"driver": "org.postgresql.Driver",
"subtype": "SDPostgreSQL",
"port": "5432",
"SavePassword": "false",
"RaptorConnectionType": "SDPostgreSQL",
"user": "your_admin_user",
"sslmode": "require"
}
}
]
}
You can use this connection with both Data Modeller and the admin functionality of SQLDeveloper. Specifying all the port, dbname and sslmode in the customUrl are required because SQLDeveloper isn't including the sslmode in what it sends via JDBC, so you have to construct it by hand.
I got the list of databases to populate by putting my username in the Username field (no password) and clicking "Choose Database". Doesn't work with a blank Username field, I can only connect to my user database that way.
(This was with SQL Developer 4.0.0.13, Postgres.app 9.3.0.0, and postgresql-9.3-1100.jdbc41.jar, FWIW.)
Oracle SQL Developer 2020-02 support PostgreSQL, but it is just the basics by adding postgreSQL driver under jdbc dir and configure by adding as a 3rd party driver.
The supported functionality:
multiple databases which can be selected at connection definition
CRUD operations like query tables
scheme operations
basic modelling support: show tables without pk, fk, connections
Not supported functionalities:
no table or field completion
no indexes are shown in a tab
no constraints are shown in a tab like: fk, pk-s, unique, or others
no table or field completions in the editor
no functions, packages,triggers, views are shown
The sad thing is Oracle should only change the queries behind this view in case of PostgreSql connections. For example for indexes they need to use this query: select * from pg_catalog.pg_indexes;
Except that it will not work if your user name and database name are differents. It sounds like an SQLDeveloper bug and i can't find any workaroud
Maybe there are some bugs in Oracle SQL Developer when it connect to the postgresql.However I connect postgresql with navicat successfully.(My postgresql username and database name are different
host= localhost/postgres? worked for me if you need a schema/database use:
localhost/postgres?currentSchema=myschema
ex: localhost/postgres?currentSchema=public
once connected, you can also use the
[Choose Database] button and pull down
sql developer postgres jdbc url for the rest of us