Unable to create connection in Oracle SQL developer . IO error - oracle-sqldeveloper

I cannot add a connection in oracle SQL developer installed.
The error I am getting is:
IO Error :The network adapter could not establish connection.
Also can anyone help me as to what user name and password it is asking?
Is there anything else I need to install.

SQL Developer is a tool which enables you to connect to the database - let's presume an Oracle one. Did you install it? If not, is there any available on the network? If not, you'll have to do that first (i.e. install a database - 11g Express Edition might be your choice, download it here), and then let SQL Developer connect to it.
As of username and password you'd use: database owner is SYS, but - you shouldn't use it for coding training - you'd rather create a new user, or unlock one of pre-installed; unless I'm wrong, 11gXE contains the HR schema (Human Resources). In order to unlock it, establish a connection to the previously mentioned SYS user (remember which password you choose for it during the installation process) and choose the SYSDBA role. Then unlock the HR user and modify its password by issuing the following statements:
alter user hr account unlock;
alter user hr identified by hr;
Now create a new connection to HR user (this time choose the "default" role); you should be able to see its tables, run queries, etc.

Make sure your oracle database is up and running.. if you are using docker you need to restart the oracle docker image in this case.
I had similar issue then i tried to restart the oracle using
docker-compose -f docker-image-oracle.yml -d up (in this case you might have a diff name).
or you can start docker image directly from cmd .

Make sure that your hostname, listener port, sid/service name, username/password are correct.
You can use lsnrctl status to get the port number.

There are four things that come to my mind:
Is your Oracle Database installed and running? If not, install it and make sure it works.
Have you entered the correct username and password? Have you entered the correct hostname and/ or port number? If hostname and port number are wrong, check the listener.ora file (if you have the permission). Alternatively, you can look into the tnsnames.ora file.
Maybe your listener is not working after all. With the command "C:> lsnrctl status" (on cmd), you can check, if the listener works. If it doesn't, run the command "C:> lsnrctl start".
Are you using the right URL?
The following link may help you:
https://community.oracle.com/tech/welcome/discussion/2547624/io-error-the-network-adapter-could-not-establish-the-connection

Related

Having Trouble with a First Time Installation of PostgreSQL 14.1 on Ubuntu 18.04

I've been having a bit of trouble trying to install PostgreSQL 14 for the first time.
I would like to apologize in advance if this question has been asked in the manner that I am about to ask it, but I do not think it has. If it has been, please direct me to the appropriate location!
I've done a fair amount of Googling on the matter, and all the information that I find seems to be rather fragmented, or I end up following a spaghetti trail of hyperlinks (a la-do-this-and-follow-this-other-link-with-more-information-than-you-need-to-understand-this-other-required-portion).
Personally, I don't want to jump around to 50 different locations on the web to try and conjure up a piecemeal solution that I believe works, only to be proven wrong later. I want to know what to do and why it works. I've tried reading the documentation, and have given up on it, because to me, it seems to assume that the server has already been set up by a database administrator.
Instead of articulating my problem directly (as I seem to be having more trouble than I would like by trying to do so), I believe it would be easier to articulate my problem indirectly by stating what my expectations would be after installing PostgreSQL for the first time.
So to start, I will mention that I'm running Ubuntu 18.04.6 LTS, and am installing PostgreSQL 14.1 with the following command:
sudo apt install postgresql-14
Before continuing, I would like to add a side note in advance, that I do not want suggestions for an alternative OS or install method. I just want to be able to get "up and running" in a common-sense fashion from this exact point.
Moving on, I know that the aforementioned command creates a *nix user called postgres.
From here, I can now indirectly state my problem using an outline of what my goals and expectations are immediately after installing the software via that command.
After installing PostgreSQL via apt, these are my expected goals:
I want any client to be able to connect to the database server from any computer where a route exists from the client to the server.
For the sake of simplicity with these stated goals, when it is directly or implicitly stated that I am trying to connect a client to the database server, I am making the assumption that the client is able to, at a minimum, ping the machine that the server is running on, and vice versa.
For now, I'm not completely worried about the database being accessible from the public Internet.
I expect to be able to access the database from any computer on my LAN, whether it is an actual LAN, or some sort of logical LAN (like a WAN or a VPN).
If I change the PostgreSQL password of the postgres user, I expect that any client logging into the database  server via the postgres user will require the password.
This means if I want to change the password to some_password via \password postgres or ALTER USER postgres WITH PASSWORD 'some_password'; (I am assuming this is how you change the login password of a PostgreSQL user), then...
I expect running psql [-h host] -U postgres -W from any host...
That when I am prompted to enter the password... 
I can only log in by entering the exact password of some_password.
Entering any other arbitrary text for the password should not allow me to log in.
I am adding this as a requirement because previous install attempts have shown me that this is NOT the case.
I expect to be able to create a PostgreSQL user account other than postgres (e.g. db_user) with a password and have it be subject to the same requirements as the postgres user.
i.e. once the new account is given permission to log in, the same common-sense login requirements to log in must be imposed, i.e. you can't get in if you don't have the correct username/password combination. 
If the process to achieve the aforementioned can be explained in such a way that it can be understood with minimal mental friction, I would be extremely grateful.
Feel free to assume that my knowledge is on par with that of a undergraduate CS student who just completed their first year of university, who also understands Linux filesystems and basic computer networking. I just want the answer to be as accessible to as many people as possible, as I am sure I'm not the only person who has struggled with installing PostgreSQL, in spite of having a power user's level of computer literacy.
sudo apt install postgresql
sudo -u postgres psql
Set a password for this user with \password or the other method you mention
sudo vi /etc/postgresql/10/main/pg_hba.conf
Make the only uncommented nonblank line in this file be host all all all md5
sudo vi /etc/postgresql/10/main/postgresql.conf
uncomment listen_addresses line and set it to '*'
sudo service postgresql restart
When you make a new user, you should also make a new database which has the same spelling as the user does. Otherwise you will need to specify the database name when you try to log in with psql -U, such as psql -U newname -d postgres -h[hhh]. Should you actually be running 14 not 10, then you will need to change the paths of the config files you need to edit accordingly.

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.

How do I view a PostgreSQL database on heroku with a GUI?

I have a rails app on heroku that is using a Postgre database. My database has > 40 tables and > 10,000 rows. I would like to delete a lot of data, but it would be much easier if I was able to view and interact with it in a GUI table. I can access my data in rails console, but it's taking too long.
pgweb is a great cross-platform GUI, and it's easy to connect to your Heroku Postgres when launching from the command line.
I installed via Homebrew on a Mac (brew install pgweb), but instructions for other platforms are listed on the site. Here's how I launch pgweb connected to a Heroku Postgres DB:
heroku config:get DATABASE_URL | xargs pgweb --url
And if you want to connect to your localhost:
pgweb --host localhost
I'm a little late here, but this may help someone else who stumbles across this thread...
If you go to your Heroku app's dashboard (through the website) > settings > "Reveal Config Vars" > DATABASE_URL, and paste that URL into the browser.
I use TablePlus for database management, when I paste the link into the browser it asks if it can open TablePlus and then I can edit my production database in real time just like I would in development.
I'm not sure what pasting the URL into the browser will do if you don't have TablePlus. I assume it will request to open any other SQL management app you might have.
As slumdog wrote in the comment to your question, you can use pgAdmin, which comes with your local Postgres installation.
This article explains how to connect your remote heroku db with pgAdmin, using heroku credentials: https://medium.com/#vapurrmaid/getting-started-with-heroku-postgres-and-pgadmin-run-on-part-2-90d9499ed8fb
From the article:
"pgAdmin is a GUI for postgresql databases that can be used to access and modify databases that not only exist locally, but also remotely. For a fresh install of pgAdmin, the dashboard likely contains only one server. This is your local server...
We have to configure a new remote server with its credentials.
right click server(s) > create > server …
Fill out the following:
Name: This is solely for you. Name it whatever you want, I chose ‘Heroku-Run — On’
Under the connection tab: hostname/address. If you go back to your datastores ‘reveal credentials’, this is the host credential. It should look like --**...amazonaws.com
Keep the port at 5432, unless your credentials list otherwise
Maintenance database — this is the database field in the credentials
Username — this is the user field in the credentials
Password — the password field in the credentials. I highly advise checking save password so that you don’t have to copypasta this every time you want to connect.
In the SSL tab, mark SSL mode as require
At this point, if we were to hit ‘save’ (please don’t), something very strange would happen. You’d see hundreds if not thousands of databases appear in pgAdmin. This has to do with how Heroku configures their servers. You’ll still only have access to your specific database, not those of others. In order to avoid parsing so many databases, we have to white list only those databases we care about.
go to the Advanced tab and under db restriction copy the database name (it’s the same value as the Maintenance database field filled earlier)."
Article contains other usefull guidelines and screenshots.
Try GUI of DBWeaver.
https://dbeaver.io/
Download it, after that you can connect your heroku postgres using Database Credentials data.
You can use Heroku's hosted DB viewer on the Overview pane of your dashboard:
Create and click the Dataclip:
Dataclip GUI is fairly easy to use, we can type and customize SQL queries at the top etc.

Use built-in SSH in Oracle SQL Developer instead of using PuTTY first

I don't have extensive knowledges about Oracle SQL Developer (Version 17.2) and SSH tunnel. I have been using PuTTY (KiTTY is the software I used) to establish SSH tunnel to connect to the database. This is the example of how I set up originally with KiTTY. Also, when I start the session where a command prompt window will pop up, I'll need to enter username and password. Let's assume the Username is username and the Password is password. And for the database, the Username is database_username and the Password is database_password.
SSH Setup:
Tunnel Setup:
I learned that you can use SSH (View > SSH) function directly from Oracle SQL Developer, and I have tried for two days but didn't work. From the information I have attached in the two pics above, will I be able to use the built-in SSH function or do I have to always use PuTTY? This is how I set up currently:
SSH in Oracle SQL Developer Setup:
How should I change the built-in SSH setup in order for me to connect to database through SSH? Will this be possible? If so, can you show me exactly what I need to enter the information into those fields (please use mine so I can follow each step)? I just think this process can be simplified within one program.
I finally found the answer for myself after two days of searching and a coworker's advice. Here is what you do to use built-in SSH function in Oracle SQL Developer that also requires SSH Tunnel. And no more PuTTY is needed for this process.
SSH Setup:
As shown in the pic below, this is what you need to enter. Please note there are two Name's fields. You can make up any name you like to use. Don't forget to perform a Test run to ensure this works. To Test run, go to SSH Hosts window, right click on the SSH connection and select Test.
Now the tricky part is here. You should see there is a Connections window on the upper left corner. Click the green plus icon button to add a New Connection.
Database Connection Setup:
Fill out the info as you can see the pic below for example. The key is to change the Connection Type to SSH, Port Forward should also point to the SSH connection that you setup above, and you should have a Service name provided by your DBA team. Once this is set, you can perform a quick Test run and see if everything is working.
The good thing about this setup is that you don't need to run PuTTY on the side. You can simply click the database name and it will prompt you the password and that is it.
P.S. I heard there is a way to store the password using SSH key but I am not familiar with the process and still trying to figure that out. Maybe post your steps here and I will definitely upvote for you.

How do I get started if I want to use PostgreSQL for local use?

Good day,
Currently I use MS Access at home for several Databases (for personal use).
At work, I use PostgreSQL, which is infinity times better. I want to start using postgres for my personally used databases, but I don't know where to start.
I've tried reading the documentation, but still don't know how to start. I don't have a server at home; is it possible I can just make a local database/tablespace? Or would I have to host a virtual server?
Note that I am willing to use other open source databases if there is an easy option out there - MS access is just so... terrible.
Thanks,
So, it seems you have Windows at home. You just need to download full installer for PostgreSQL:
http://www.postgresql.org/download/windows/
After installation it will automatically add starting postgres server as a service on local machine. That means, server will always run in background, but you can disable that later, or just uninstall.
After that, you can use pgAdmin (included in default installation package) or other client tools to access the DB engine.
UPD in pgadmin, create connection with this settings:
'localhost' as hostname;
port - 5432;
user, database - postgres (for testing purpose only - you should create your own user and tables with restricted rights later).
Password for postgres (that is DB admin user) must be entered during installation process.
Server settings are stored somewhere here:
"C:\Program Files\PostgreSQL\9.3\data"
pg_hba.conf - Client Authentication Configuration File
postgresql.conf - Configuration File