connecting to oracle database on Windows - windows

I have two machines on my network:
pc-1 is running on Windows XP SP3, IP 192.168.1.15
pc-2 is running on Windows Vista, IP 192.168.1.16
Now I have loaded Oracle 11gR2 on pc-2 (Vista) and the listener is running with the following settings: address=192.168.1.16 and port=1065.
I am trying to connect to Oracle database via pc-1 (XP) using jdbc thin driver but I get the error The network adapter could not establish the connection.
My JDBC url: jdbc:oracle:thin:#192.168.1.16:1065:ora
The pc-2 is reachable, I checked it by ping 192.168.1.16
I tried a few things from PC-1:
TELNET 192.168.l.16 1065 gives error Connecting To 192.168.1.16...Could not open connection to the host, on port 1065: Connect failed.
The firewall on pc-2 (vista+oracle) is turned off so I don't think firewall is blocking port 1065.
tnsping 192.168.1.16:1065 gives error TNS-12535: TNS:operation timed out
sqlplus sys/sys#//192.168.1.16:1065/ora as sysdba but it gives error
ERROR:ORA-12170: TNS:Connect timeout occurred
Some of the commands output on PC-2
netstat -a
LOCAL ADDRESS------------ FOREIGN ADDRESS-------------- STATE
192.168.1.16:1065----------------- PCNAME -------------------LISTENING
Can anyone please specify in details what shall I do? I am trying to do this first time so no idea about what is going wrong?

You have to give the proper SID details in the tnsnames.ora file located under
for Linux:
/home/oracle/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora

You don't say how you're connecting - I am assuming through TNS?
Did you specify the port of 1065 in your TNSNAMES.ORA file on the XP system?
Can you connect from your XP system using EZCONNECT? That takes tnsnames.ora out of the equation.
sqlplus user/pw#//192.168.1.16:1065/db_name

ERROR:ORA-12170: TNS:Connect timeout occurred
this error usually means failure network connection
It's simple
shut down your windows firewall

Related

psql: could not connect to server: No such file or directory on Windows

When I try to connect to my postgresql database with psql I receive the error message:
D:\>psql -U postgres
psql: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/tmp/.s.PGSQL.5112"?
A similar error I get when using createdb:
createdb: could not connect to database template1: could not connect to server: No such file or directory
next two lines are identical to the psql error.
I can start pgadminIII without problems and access my databases. when I check the properties of the connection it uses port 5432. When using process explorer I see about 5 postgresql processes, though none accessing port 5432. The solutions I found in this forum are about linux/osx platforms, which I am not able to translate into a windows solution.
Could anybody tell what is wrong/what I am doing wrong and suggest a solution?
Thanks for your time.

JDBC Connection from MAC OS(EL Capitan) to Prebuilt Oracle VM

I must have searched the entire net for a solution but no success.
I have installed a DeveloperDay prebuilt Oracle Linux 7.3 form the following site: http://www.oracle.com/technetwork/database/enterprise-edition/databaseappdev-vm-161299.html
I am able to connect to the database through SQL Developer using configurations like
Connection type : Basic
Username : scott
Password : oracle
hostname : localhost
Port : 1521
Service name : orcl
Connection is successful and I am able to query properly.
But while trying to connect from jdbc from eclipse I am unable to connect. I am getting various errors for various attempts like
jdbc:oracle:thin:#localhost:1521:orcl
Listener refused the connection with the following error:
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
jdbc:oracle:thin:#localhost:1521:orcl12c
java.sql.SQLException: ORA-01017: invalid username/password; logon denied
(username and password is entered as scott and oracle respectively)
jdbc:oracle:thin:#127.0.0.1:1521:orcl12c
java.sql.SQLException: ORA-01017: invalid username/password; logon denied
Please help to resolve this issue.
Because you try to access to a distance database, you consider VM like it is localhost and this is wrong, in fact it is another machine.
To solve this problem you should to use the IP Address of this VM not localhost, and this not easy you should to make some configuration of your VM you can follow this manuals here:
How to access Oracle DB in VirtualBox from Host (windows) and How to access localhost on Virtualbox host machine
and here
Connecting to Oracle from Your Host to a VirtualBox Guest
Hope this can help you.

Postgresql is not allowed to be connected remotely

Could someone help take a look this weird problem? I'm still not able to connect remotely to my Postgresql.
My Steps:
Download and install the latest Postgresql to my local machine
Setup postgresql
Create a DB
Modify "pg_hba", add row "host all all 0.0.0.0/0 md5"
Modify "postgresql.conf", make sure "listen_addresses = '*'"
Restart postgresql service
Open local PgAdmin, and connect to DB <-- Success!
From Remote desktop, do the same thing as #7 <-- Failed!
Error Message:
"Server doesn't listen"
"Could not connect to server......accepting TCP/IP connections on port 5432?"
I found "TCP 0.0.0.0:5432 Listening" when I type "netstat -a"
I checked firewall, it's not enabled
......
Can someone please help? Does anyone encounter this situation?
P.S, my os is Winserver 2008
Thanks in advance~
If you're connecting to the local machine via RDP then you'll be connecting via localhost and no firewall or LAN/WAN/NAT settings should affect pgadmin.
When you edit the pg_hba and postgresql.conf files Server 2008 doesn't usually let you edit them directly where they are. I usually copy them out edit them and then paste them back in. You'll need to authorise the paste from an Admin account.
I usually have a separate rule in "pg_hba" with "host all all 127.0.0.1/32 md5" for local connections. Also ensure when you restart the service that it is running under the user "postgres" and not as some other user.

Connect DbVisualizer to HSQLDB on Mac

I need to connect DbVisualizer to HSQLDB. I've installed both on my mac (OSX 10.6.9). I've installed DbVisualized 8.0.5, and HSQLDB. I have both open, but when I try to ping the server, I receive the error message: "Cannot connect to 'localhost' on port 9001." The message below shows up in the Connection Message window:
An error occurred while establishing the connection:
Long Message:
java.net.ConnectException: Connection refused
Details:
   Type: java.sql.SQLTransientConnectionException
   Error Code: -1301
   SQL State: 08001
By default, when you run the HSQLDB Server, it shows some messages in the window. The last maessage should indicate susseful startup.
[Server#80fa6f]: 2011-11-12 21:03:24.904 HSQLDB server 2.2.6 is online on port 9001
[Server#80fa6f]: To close normally, connect and execute SHUTDOWN SQL
When you ping from DbVis, the server rejects the data because it's not valid data for making a connection. It shows an exception. This is normal behaviour. On the DBVis side, it should return success after the ping.
You should then connect from DbVis and it should work.
You must use the same HSQLDB jar on both DbVis and HSQLDB (you probably have done this).
You can also double check by executing the HSQLDB (version 2.2.x) jar, which brings up its own database manager and allows you to connect to the server.
One likely cause is network problems. You can try the IP address 127.0.0.1 instead of 'localhost'

Using oracle db through ssh tunnel. Error "ORA-12541: TNS:no listener"

Hello I've got a problem accessing Oracle DB from our datacenter through a tunnel.
We've got a pretty standard datacenter with one machine being accessible from the outside
(I put it's IP in the /etc/hosts file as dc) and the Oracle DB inside. The IP address of our oracle database on internal network is 192.168.1.7
To create a tunnel I'm using the command:
ssh -L 1521:192.168.1.7:1521 root#dc
and of course it works (sometimes I also add some debug -vv to see if anything is passing through).
Now the difficult part - connecting to Oracle. I installed instantclient 11.2. and my tnsnames.ora looks like that:
testdb =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dbname)
)
)
And when I try to connect using the command:
./sqlplus username/pass#testdb
It starts connecting through the tunnel (I see it in the ssh debug) but then it fails
telling:
./sqlplus username/pass#testdb
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jan 13 20:46:07 2010
Copyright (c) 1982, 2009, Oracle. All rights reserved.
ERROR:
ORA-12541: TNS:no listener
Enter user-name:
When I'm trying to execute this same command on when I'm on the intranet it works (obviously the only difference is that in the tnsnames.ora HOST we have 192.168.1.7 and not the localhost).
I also tried to use the simple command line:
./sqlplus username/pass#//localhost:1521/testdb
or alternatively
./sqlplus username/pass#//localhost:1521/testdb
But nothing helped :)
I would appreciate any help or suggestions. Am I missing some ssh flag to make it possible?
Probably the log file:
***********************************************************************
Fatal NI connect error 12541, connecting to:
(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=DBNAME)(CID=(PROGRAM=sqlplus#velvet)(HOST=velvet)(USER=johndoe))))
VERSION INFORMATION:
TNS for Linux: Version 11.2.0.1.0 - Production
TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.1.0 - Production
Time: 13-JAN-2010 20:48:42
Tracing not turned on.
Tns error struct:
ns main err code: 12541
TNS-12541: Message 12541 not found; No message file for product=network, facility=TNS
ns secondary err code: 12560
nt main err code: 511
TNS-00511: Message 511 not found; No message file for product=network, facility=TNS
nt secondary err code: 111
nt OS err code: 0
where velvet is my local hostname and johndoe is my local username.
Why is it sent to the other side?
UPDATE:
After investigating a little bit more from inside datacenter and it looks like:
- the first connection is going to the port 1521
- but then sqlplus is redirected to the port number > 3300, which is different everytime and incrementing by 3 (at least few tries I had)
- when we are trying to connect trough a tunnel sqlplus will try to connect to localhost and it will obviously fail
So the error "No Listener" comes probably from the fact that we are not redirecting those ports. Is there any way (probably some option in tnsnames.ora file) to force some specific port to be used?
Look into Metalink ID 361284.1 (Edit: effectively not public, but find the info here)
It seems like Oracle Connection Manager would be your option. It basically handles the port redirects inside the firewall. I haven't used it before, so cannot advise you further.
Update: Another way to go would be to use MTS, configure dispatchers with certain ports and open these ports in the firewall. You wouldn't have to install additional software for this, but connecting through shared server may require increasing LARGE_POOL_SIZE, among other considerations. So you'd still need the DBA role to change the DISPATCHERS parameter. You'd also have to bounce the DB.
Normally this should work. I would not use a default listener port as an entry for the ssh tunnel but that should not be the problem. I would also not user the root account to create the ssh connection, preferably a dedicated regular account. Are you using shared servers or does the database happen to be a RAC database with a load balance configuration?
A nice explanation is here How can I connect to ORACLE DB through ssh tunnel chain (double tunnel, server in company network) ?, a bit more complicated .....
update
checkout DbVisualizer, it now has integrated ssh tunneling. I think it is worth to al least give it a try. It's not free but good. Multi platform and multi database and very flexible.
In my case the problem is that the DB server has several IPs and when I used SSH tunnel it was connecting to wrong different one.
So try to check, if the destination IP is the same as the IP in the listener.ora file on the DB server.
Can you try to make a trace to determine exactly what is happening:
For server trace, try here (be carefull! all the new request will be traced and the server can be collapsed).
For client trace, checkout here.
MJ! Your tunnel is only for the initial tcp connect, your own LISTEN port is not tunnelled, and probably unimplemented. Firewall should allow a connect back to you, similar to active FTP.
All ports for Oracle are documented quite extensively starting page 670 of "Building Internet Firewalls" 2/E Chapter 23, paragraph: Oracle SQL*Net and Net8. You can view it on SafariBooksOnline.com
ISBN 1565928718
Perhaps your listener haven't been started yet. Try run "lsnrctrl start" command.
Also a good explanation is here connection to an oracle database though a SSH secure shell which worked for me.
Open putty and on the session page, enter the name of a server and make sure SSH is checked. The server can be any server that you have a
username and password to login with. I use one here called BLUEBIRD as
I own it!
On the connection->ssh->tunnels page, uncheck both options at the top ("Local ports accept ..." and "Remote ports do the same").
Enter 9999 (or any port above 1024 as the Source Port.
In the destination, enter the database host and port as per tnsnames. In my case, this is a server called GREENBIRD and a port of
Enter this as server:port.
As the port being forwarded is on your desktop, check the "Local" option. Leave "Auto" checked as well for the IP version.
Click the Add button. You will see L9999 greenbird:1521 (your will differ) in the list of forwarded ports.
Go to the session page again, Enter a name for your saved session and click save.
Click open. Supply a username and password for the server (BLUEBIRD in my case). You will login a normal ssh session to the server named
BLUEBIRD.

Resources