0

I have an online website. When I'm logged in at my work computer I have 'automatically' connection to the local Oracle database.

Can I connect to this local database from my online website?

I guess I need the host name of the computer which is running the Oracle database.

But I can't contact my DBA at the moment. Can I somehow figure it out myself?

Jamgreen
  • 10,329
  • 29
  • 113
  • 224

1 Answers1

0

Depending on your privileges, and on the version of Oracle you're on, one of the following should give you the server name:

select sys_context ('USERENV', 'SERVER_HOST') 
from dual;

or

select host_name from v$instance;

If this works, bear in mind it may well be the first step in a frustrating process that ends with you banging your head against your desk before calling your DBA and network/server guys. There will probably (hopefully!) be a lot of security concerns to address.

Bacs
  • 919
  • 1
  • 10
  • 16
  • Both SQL strings work :-) Can you recommend any good software to check if I can establish a remote connection? Right now I do my SQL queries in VBA but I guess professional DBAs have a suitable program to do all these kind of queries. – Jamgreen Nov 18 '14 at 14:24
  • If your web server and database server are both on your work's LAN, or both in the same DMZ on the network, you might be able to connect without calling your infrastructure people. You could try downloading SQL Developer from Oracle and installing it on the web server. Set up a connection to the Oracle server on port 1521 and try to login. You might be lucky. If there is one or more firewalls in between the two servers, at the very least you will need ports opened up, and it may be that your work's security policies prevent you altogether. I refer you to the last paragraph of my answer! – Bacs Nov 18 '14 at 14:36
  • Okay. Thank you :-) One last question: If I'll use Python I can connect with `cx_Oracle.connect(username/password@host:port/service_name)`. I know my username and password and from your answer I got my host name. I just keep getting the error `ORA-12154: TNS: could not resolve the connect identifier specified`. – Jamgreen Nov 18 '14 at 14:56
  • I've read from http://stackoverflow.com/questions/245465/cx-oracle-connecting-to-oracle-db-remotely that it's better to use `cx_Oracle.makedsn(ip, port, SID)` but I don't know `ip` and `SID`. – Jamgreen Nov 18 '14 at 15:02
  • If you're on your work network, try `ping yourOracleServer` at a command prompt to get the IP address. The SID will be the name of the database. If you don't know it already, you'll probably have to ask your DBA. – Bacs Nov 18 '14 at 15:14