How to fetch data from oracle data base from another computer - oracle

I am trying to execute one simple desktop application in my system that is built upon java swing.
This application fetches the data from the oracle database which is present in computer A.
I did the development in computer A and built its jar and kept the jar in another system.
I have started all the services of oracle and created an ad hoc network between the two systems, but I am not able to execute the application from another computer. I googled a lot and did the mentioned changes. Still I am getting the same error of TNS listener.
IOException: The network adapter could not establish the connection.
finally I thought to put my code here. please look at the below code:
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connection =
DriverManager.getConnection("jdbc:oracle:thin:#//xxx.xxx.xxx.xxx:1521/XE"
,"system"
,"system" );
Please help me on this.
I have also tried modifying the tnsnames.ora file but was not helpful. can anybody please help me on this.

Check the listener.ora file - what is the IP address the service is binding to, i.e. what is the IP address specified in this file? If 127.0.0.1, that will explain why it works on Computer A but not B.
If this is the case you should fist stop teh listener service, backup the listener.ora, edit listener.ora, changing the IP address to the appropriate one for Computer A (accessible from Computer B), restart the listener, and retry.
Use tnsping to test the connection works, if you don't have TNS ping you can try "Telnet hostname port" (e.g. telnet computer-A 1521) and if it returns blank screen and flashing cursor on top left then the service is up.

Related

What is the cause of this problem "IO Error: The Network Adapter could not establish the connection" on Sql Developer?

I make a connection for connect to the Database Server (other machine).
Then I found "An error was encountered performing the requested operation:
IO Error: The Network Adapter could not establish the connection
Vendor code 17002".
Please look the picture in URL below.
I tried to make a connection but can't access but my team can access it.
My friend used TNS connection type and I did everthing similar him but can't access. I tried to use JDBC thin for connect but can't also.
I had the old connection which I can connect but why I can't connect the new connection.
You're trying to connect to a machine on a network that SQL Developer is unable to reach.
For a TNS connection,
Look at the appropriate TNSNames entry (you will have a tnsnames.ora) file, and find the IP address or network name associated with the connection you're trying to establish -
And then start by trying to ping that resource.
In this case, i'm trying to talk to a database on MY machine, on port 1521. Yours should look quite different.
If you're using a basic connection, then you can look at the connection properties and see what machine/port you're trying to communicate with.
Ping
If you can't reach that machine from your machine, there's zero chance you can connect to a database there.
So, always start with a ping.
Once you see that you can get to that machine, if you're still getting that message, the next thing to think about is blocked ports, the listener defaults to port 1521, but you'll see that in the TNS descriptor as well.
It usually happens when a another process is running on the same port or there is an absence of listener.
Go to Run>services.msc>OracleXETNSListener>Start
Try to reconnect.. Even if the error still prevail then go to cmd
Use code:
npx kill-port <portnumber>
The port number by default is 1521, but you can check the port number in database properties.
It is possible, that your connection is forbidden by the firewall -
go to Control Panel\System and Security\Windows Defender Firewall - Advanced - Outbound Rules - Add a rule. (If you have some antivirus firewall, add rules there)
Create a temporary TCP rule for your port and another rule for UDP. Allow all nets and comps.
Check the telnet connection as cmd -> telnet ->
open remote.host.address PortNumber
If you can connect now, then the problem IS in firewall - edit your new rules, setting the hosts and nets exactly.
This error is because your sqldeveloper is not able to reach the database server's sql service.
One reason could be lsnrctl is down for some reason.
If you have access to machine where database is installed.
In Windows machine, follow: https://www.youtube.com/watch?v=r9pHqOfV2f0&ab_channel=TLinaTutorials
In Linux/macOS machine: Go to $ORACLE_HOME/bin and check status of lsnrctl
execute from $ORACLE_HOME/bin lsnrctl status, if it's down. Then restart it by lsnrctl start.
Check the details of connection in command output like SID, PORT, HOST etc. and try connecting again from sqldeveloper.

What does Oracles 'alter system set local_listener' do exactly

Why I am curious:
I have always had issues when installing an Oracle Express Database. As in I have never had it work right the first time round. The next time I boot my computer after installing Oracle Express I consistently receive the common error:
TNS-12505: TNS:listener does not currently know of SID given in connect descriptor
I have managed to fix this issue using various methods however I have learned that the best method that works for me these days is to Reconfigure the Listener using SQL Plus. When the Listener fails SQL Plus is the only way I can connect to the OracleXE Server and after searching the Internet I'm not alone here.
The DDL that fixes this error - run from SQL Plus:
alter system set local_listener='(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))' scope=both;
The Question:
Why does re-configuring the Listener work? What does it do? I monitored my listener.ora file along with my TNSNames.ora file and they remain the same before and after I run the above code. So what did it do?
I read this entire Oracle LISTENER Documentation and I did not come out of it enlightened. Can anyone enlighten me?
Why does re-configuring the Listener work?
You are not reconfiguring the listener. That's why you don't see the listener configuration file change. You are changing the database configuration. The spfile is updated because the command you used had scope=both, which means the change is applied immediately - in memory - and written to that file, so it persists on database restart.
From the docs:
LOCAL_LISTENER specifies a network name that resolves to an address or address list of Oracle Net local listeners (that is, listeners that run on the same system as this instance).
and the default is:
(ADDRESS = (PROTOCOL=TCP)(HOST=hostname)(PORT=1521)) where hostname is the network name of the local host.
See also the alter system REGISTER clause:
Specify REGISTER to instruct the PMON background process to register the instance with the listeners immediately. If you do not specify this clause, then registration of the instance does not occur until the next time PMON executes the discovery routine. As a result, clients may not be able to access the services for as long as 60 seconds after the listener is started.
So what this means is that when the database starts, and then periodically, it tries to register its service name(s) with the listener; and it gets the info about the listener from the local_listener parameter. (There's also a remote_listener for data guard, not relevant here.)
Because the default is hostname the PC name is used directly in that parameter, and that will often resolve to the PCs LAN IP address (which can change each reboot to add to the confusion, if the IP is assigned by DHCP), which could be stored instead. If you're lucky the hostname will resolve to the same as localhost, but that isn't the case for you.
So... the database looks up its init parameter, and as a result tries to register with a listener at say 192.168.1.2. But the listener has started on localhost so it is listening on 127.0.0.1. The DB fails to register its service name, as it can't reach a listener; though that is only apparent if you look in the alert log. If you run lsnrctl services it won't show anything.
When you change the init parameter you are telling the DB to try to register against a listener on localhost instead - and as that is where it is actually listening, registration now works, and the listener recognises the service name on subsequent connection attempts. (Your question refers to the error message about SID, which is different, and not solved by your change.) Running lsnrctl services will now show the service name too. But that is a runtime, dynamic thing via the registration - not a change to the permanent configuration of the listener.
It's possible to have the listener listen on more than one address. The main thing is that the listener.ora, tnsnames.ora (if you use TNS aliases) and init parameter use consistent host names or IP addresses, so they are all resolving to and referring to the same thing, whether that is localhost (only reachable from that PC), or a LAN address (reachable across the nwtwork) or both.
You can also have an entry in the tnsnames.ora for the listener itself, rather than just for DBs. You can then use that TNS alias as the local_listener target, instead of spelling put the address and port, possibly making it easier to change later if needed.

ORA-12514 after restoring server from snapshot

We have a series of Amazon Web Services servers running Amazon Linux and Oracle XE, which is used by a local app. OracleXE installs and runs just fine, our app can connect to the DB, everything is great.
For one of our particular servers, we needed to shut it down and archive it. Today, I need to bring it online. This is done by setting up a new AWS instance, creating a new virtual hard drive from backup snapshot, setting up a new public IP for the server and changing DNS settings to that the old domain points to the new IP, connecting up the restored virtual drive as the main drive, and starting it up.
OracleXE doesn't want to work. Using sqlplus to connector to localhost:1521/XE produces "ORA-12514: TNS:listener does not currently know of service requested in connect descriptor".
This system was working just fine when I snapshotted it and archived it the first time, and I hadn't changed any settings since restoring it. Everything should be exactly the same, so why is OracleXE now not working?
The listener.ora and tnsnames.ora had the host defined using the server's public domain name. I tried changing that to localhost, but it's still not working.
The only things I can think of that will be different are the server's public IP address, and the "rsa2 key fingerprint" (what Putty complains about due to the SSH key being the same but it being a new AWS instance). All the advice I've seen so far is for fixing config errors for ORA-12514 when setting up a new system or after restarting, but this is a system that was working fine but has been restored from snapshot.
Most likely, your listener uses dynamic instance registration.
For that to work, your listener must be listening to the default port (1521) or your instance must use the local listener parameter that defines the address of the listener where the instance should register it's existence.
So, check your local_listener parameter, check the servers tnsnames.ora and listener.ora. Also check your clients tnsnames.ora, it should point to your new server and listener.

3 layer application non networked?

I have a system named Windchill which runs in a CentOS 5.7 virtualbox;
The system consists of apache, oracle 11g, listener, windchillDS(openLDAP) and the application core (method server) which is a java process. All installed in the same vm(monolithic)
My question is related with the network, The system runs smooth on the network, but once I remove the network cable it stops working and the method server keeps restarting with the socket timeout error.
Im not a IT specialist, I manage the internal configuration of the system and I dont have an specialist to help me right now but I need desperately to make it run non networked in a laptop to show it for a customer.
I just want a hint of where may be the problem:
Does oracle runs non networked? Which configurations do I need to make it run without a network?
Maybe the problem is the listener?
I guess the problem is the oracle because of the socket timeout error with the database but Im not sure...
Sorry this is long and probably needs more explanation, please ask whathever you want!
I found this tip in another forum specific for the windchill product(login needed)
http://portal.ptcuser.org/p/fo/st/thread=52005&posted=1
It is related with Linux configuration to resolve the IPs:
"Edit your /etc/resolv.conf to look like this when not connected to a network:
domain local domain
search localdomain
nameserver 127.0.0.1"
Worked perfectly!
Thank you for your prompt answers guys!!!

What could be wrong: ping works fine but tnsping works intermittently

We have oracle 10g running on windows server 2003. A machine which runs an application using that database has as of a few weeks ago suddenly started having connectivity problems. Today we ran the automatic updates for windows server and the problem has only gotten worse. I realize this isn't enough information for anyone to diagnose the problem but perhaps you can get me pointed in the right direction with the following more specific scenario:
From this machine we can ping the server with absolutely no problem and, being physically close and on an intranet the return is very fast.
However, when we run tnsping I have seen 3 different results within a few minutes of each other.
tnsping returns just fine and in a reasonable amount of time
tnsping returns but only after a real long time (several seconds)
tnsping results in an ora-12560 protocol adapter error
At the same time I can tnsping the server from my machine with no problem.
Can anyone point me in the right direction?
I'd try to check the following:
do traceroute from the app server and from your machine check for anything abnormal
check tnsping from various other machine and try to identify a pattern
try a tcp/ip sniffer to see what is going on at both ends of the connection
get oracle support involved
To help eliminate DNS issues from the equation, specify the host's IP address in the TNSNAMES.ora file for your connection instead of a hostname. Are you using DHCP?
Have you eliminated hardware as the problem - have you tried a different NIC?
Before calling Oracle, I would create a trace file for a Fail case.
TNSPING.TRACE_LEVEL
Purpose
Use the parameter TNSPING.TRACE_LEVEL to turn TNSPING utility tracing on, at a specific level, or off.
Default
off
Values
* off: for no trace output
* user: for user trace information
* admin: for administration trace information
* support: for Oracle Support Services trace information
Example
TNSPING.TRACE_LEVEL=admin
Before involving oracle in this issue, get some help from your network administrator for the following test. First enable verbose logging on the database in the listener. Enable logging on the client via sqlnet. Go to the machine that is having trouble with tnsping, have the network administrator run a network tool to trace tcp packets from there. Perform the tnsping and see if what packet are being sent, what dns lookup are being made, what route is being taken. On the database see if the listener actually receives a ping from the client. If not then see where along the network to the database the problem is. Is it nameserver resolution? Is it a bad network cable, bad switch port, etc. Your network admin is your best friend for this problem. Do the same test via sqlplus with a simple connection and see what the client is logging.
Make sure there is no other machine on the network with the same IP address. A method would be unplug your machine from the network and see if you can still ping it. If you can then this is the problem.
If the server doesn't have a domain-name setup at a dns server, then add it's ip address and name to the host file on the server; this (the server not being able to find itself in dns) has been known to cause tns timeouts.

Resources