How do I connect to the Database on a different server? - oracle

I have a machine A which has DB server on it.
I have a machine B which has Oracle Client installed on it.
I modified the tnsnames.ora file in machine B by adding the following:
TRIAL1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = machineName.example.com)(PORT = 1521)(QUEUESIZE=100))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = Trial1.world)
)
)
Yet, I cannot run the command sqlplus name/pwd#trial as sysdba on machine B successfully. It throws an error stating "insufficient privileges". Are there any modifications needed on the sqlnet.ora or tnsnames.ora file on machine A?

In order to be able to connect remotely as sysdba you need to grant that system privilege to user that needs to do that.
grant sysdba to name;
From now on you can connect from any machine using sqlplus name/pwd#trial1 as sysdba. The name is the username defined in the database that you connect to, no matter from which OS account you connect or from which machine you connect, as long as the connection can be made.
Question that remains is: do you need to work as sysdba in that database. Don't do that unless you know what you are doing. Effectively you work as SYS, the owner of the catalog. The slightest typo can make your database dead as a dodo.
For most, even a regular dba account is already too much. Create a regular account ASAP give it the needed privileges and use that one to do your work. The needed privileges are the minimal privs needed to do the job (create session, create table, create procedure etc. (almost certainly not dba))

Related

port number of database produce error message

I'm writing a simple java program (Jcreator as my IDE) to connect with Oracle Database (using SQL Plus / Oracle 10g). I first downloaded the jar file and copied it into bin directory in oracle directory. Then, I added the jar file to my JDK and wrote this code :
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection(
"jdbc:oracle:thin:#localhost:1521:amani","system","a123");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from emp");
while(rs.next())
System.out.println(rs.getInt(1)+" - "+ rs.getString(2)+" - "+rs.getInt(3)+"\n");
The problem is when I use the default port number 1521, I do not get any results and no error messages appear.
and I know that I'm supposed to use my own database port number which is 1158, but then I get
java.sql.SQLException: Io exception: Bad packet type
What am I doing wrong, can someone help?
I don't know Java so - the following might be irrelevant nonsense so I apologize if that's the case.
Anyway, shortly: 1521 is most probably the port you should use (not 1158). Credentials you provided (username = system, password = a123) are wrong; use username = scott, password = tiger instead
A longer version of the above statement: you should have access to the database; seeing your code, it is installed on your own computer. Is it up and running, i.e. can you connect to it via SQL*Plus?
Saying that you are
supposed to use my own database port number which is 1158
well, I doubt that. If you installed everything by default, then your database port number is 1521, while 1158 is reserved for OEM (Oracle Enterprise Manager database console) so I don't think that 1158 is what you should use. See Managing Oracle Database Port Numbers.
Furthermore, is your database name really "amani"? That's what this
"jdbc:oracle:thin:#localhost:1521:amani","system","a123"
-----
this
suggests. In order to get its port, TNSPING it using command prompt (I've removed unnecessary part of the output): I can't tnsping amani (obviously, I don't have access to it)
c:\Temp>tnsping amani
TNS-03505: Failed to resolve name
but I can tnsping my own XE database:
c:\Temp>tnsping xe
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = my-laptop)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))
OK (110 msec)
See? It is "OK", and its port is 1521. Do it on your computer in order to find that information.
Finally, username and password: you used one of special, most powerful users in your database, SYSTEM (another one is SYS). It doesn't contain the EMP table - it belongs to user SCOTT (whose default password is TIGER).
As you're on Oracle 10g, if I remember well, SCOTT is one of pre-installed schemas so you should be able to connect to it. Check it as following: on my XE, I'm connected as SYS:
SQL> select username, account_status from dba_users;
USERNAME ACCOUNT_STATUS
------------------------------ --------------------------------
SYS OPEN
SYSTEM OPEN
ANONYMOUS OPEN
SCOTT LOCKED
HR OPEN
<snip>
SQL> alter user scott account unlock;
User altered.
SQL> alter user scott identified by tiger;
User altered.
SQL> connect scott/tiger#xe
Connected.
SQL> select count(*) From emp;
COUNT(*)
----------
12
SQL>
I hope you understood what I did.
That much about Oracle part of the story; I really wouldn't know what to do if that doesn't help, in order to make your Java side work. Hopefully, someone else will be able to assist.

I install oracle client 11g on my machine .I am not give any username and password of course I am not get that window at initialisation time

How connect to the db .I am tried with the following username and passwords system/manager ,scott/tiger etc .But no luck I am still not connected to the db.And also I am getting TNS:Protocol adapter error. I am not understanding why? I also gone through the services for start/restart But there is no at least one single Oracle service file.How I am getting this oracle services as well as how I connect to the db.Please some body help me. My system operating system windows XP.. I am installing oracle client 11g on windows Xp operating system.
Oracle client is software that allows a remote computer to talk to Oracle. If you were to write a piece of software that communicated with the database, you would use the Oracle Client to facilitate that communication.
If you need oracle database in your machine you can go for Oracle database version like Express edition and Enterprise, standard edition. You can't create any database using the oracle client software.
Note : While installing oracle client(any version) it won't ask any username and password.
Steps to connect Oracle client to Oracle database
Consider your oracle server tnsname like below
ORA11 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORA11)
)
)
Place above tnsname text into your tnsname.ora file (C:\app\oracle\product\network/admin/tnsnames.ora)
After that check your sql*plus prompt like
tnsping databasename
sample output
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION= (ADDRESS= (PROTOCOL=TCP) (HOST=gracelan)
(PORT=1525)) (CONNECT_DATA= (SID=GRA901m)))
OK (80 msec)
connect username/password#dbname
can you please provide your tnsname ping output.
Use your server Name like tnsping orcl in cmd.exe
When ever you want to connect dbserver from dbclient we must know the username and password.That are all knows to the who install the Database server not Database client. From where ever we want to connect to the db we must and should know the username and password .i.e either from dbserver or dbclient.IN OTHER words when installing oracle client we don't enter any username and passwords.Because in client there is no database .we just connect the server db only.The password and username knows whose install DB server not client.From client we connect the server by using server username and server passwords...

ODBC Data Source with Oracle 11g

I am trying to connect to a Primavera P6 Database hosted on my network with driver Oracle in OraDb11g_home1. I currently have readonly access via the frontend, which I can successfully navigate records this way.
However, every attempt I have made to connect with a DSN has failed. I'm assuming that if I can connect to the frontend (even if readonly) that I should be able to connect via DSN with the same credentials?
The farthest I have gotten leaves me with an invalid username/password error. Here are the connection details:
in tnsnames.ora:
CHPPRIPA.world =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = xamxilux002)(PORT = 1521))
)
(CONNECT_DATA =
(SID = CHPPRIPA)
)
)
I have similarly tried connecting using JDBC Driver (using a connection string) with the same username and password where
driver = "oracle.jdbc.driver.OracleDriver"
and
db_url = "jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=ramxilux002)(PORT=1521)))(CONNECT_DATA=(SID=CHPPRIPA)))".
username = "csdba" # (Central Services Database Admin);Level 1 - P6 Client - View Only
I still get the same invalid username/password error.
Am I wrong in believing that the same credentials should get me the same access in both places? Anyone experience this problem?
The user interface known as P6 Professional or P6 Web uses different login credentials than what you need to get into the database. Only the DBA can give you those credentials.
Additionally, I would like to ask why you feel you need access to the database. This will impact how you connect to the database and which schema to use.
The SID you are showing is not typical of the "stock" installer/upgrader for Oracle databases running Primavera P6.
There are FIVE schemas in the Primavera P6 database. It is strongly recommended that you not attach to any except the extended schema for reporting.

TNS:name lookup failure

I have a stand-alone workstation at work that connects to an oracle database. It's been working fine for years and then all of sudden I get an error:
[INTERSOLV][ODBC Oracle driver][Oracle]ORA-12545: TNS:name lookup failure
When I ping the server I am trying to connect to from the command prompt, it replies back with the right IP address. If I do a TNSPING, that seems to be ok as well.
I have a separate PC that is on the computer network and it connects to the server just fine - it doesn't have that error above in bold.
There is another, different oracle database that I connect to on that stand-alone PC and it's still working fine. So, it's not like I lost the ability to connect to any or all Oracle databases - just something about this one.
I'm confused why it won't work and haven't had any luck trying to fix it. I'm not sure how to proceed.
Any help would be appreciated.
Try defining the environment variable TNS_ADMIN to point at the location where your TNSNAMES.ORA file resides.
EDIT:
Can you connect with SQL*Plus directly?
If it's installed, this should work (replace user and db with the userid and database to conenct to):
sqlplus user#db
Failing that, try connecting with EZCONNECT:
Modify sqlnet.ora file:
NAMES.DIRECTORY_PATH=(TNSNAMES,EZCONNECT)
Change your ODBC Connection in the Oracle ODBC Driver Configuration wizard to use the EZCONNECT string:
Replace the TNS Service Name with:
<db_host>:port/<db_name>
e.g.,
MYHOST:1521/MYDB
This points to the database MYDB on host MYHOST at port 1521 (the default port).
Try testing the connection. If that fails, try using the IP address instead of the hostname.
Given your TNSNAMES entry from your comments:
ESTRNP = (DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = ESTRNP)(PORT = 1521))
)
(CONNECT_DATA = (SID = ESTRNP))
)
You might try changing the CONNECT_DATA line to:
(CONNECT_DATA = (SERVICE = ESTRNP))
It is possible that the SID of the database was changed. Is this entry the same as the entry on the machine that works?
do you have recently install any other oracle software?
It is possible that you have multiple tnsnames.ora files on different locations and the odbc driver finds the wrong one.
Inspect you path environment variable, whether the path to the right one is at the first place.

Can't create Database Link to remote DB in Oracle-DB

We have a CRM system in our company, which uses an Oracle 11g database. It is developed by a third party vendor.
We do not have access to the server which runs the CRM system. But nevertheless, we have working DBA login data available to us (SYS user). It consists of:
server IP: 172.1.2.3
port: 1521
SID: abc
user: sys
password: *
We can use this to access the DB with Oracle SQL Developer 3.1 (Connections >> Properties)
Now parts of the data must be copied out of the CRM-database into an other Oracle database, which resides on another server.
To my understanding, I'd need to create a database link in my target database. I tried something like this:
CREATE PUBLIC DATABASE LINK xxx CONNECT TO sys IDENTIFIED BY ***** USING 'MYTNSENTRY'
My tnsnames.ora is as follows:
MYTNSENTRY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.1.2.3)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = abc)
)
)
.... and my listener.ora look like this:
MYLISTENER=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=172.1.2.3)(PORT=1521))
))
SID_LIST_MYLISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=MYTNSENTRY)
(ORACLE_HOME=C:\somepath) # path to Oracle home of target DB
(PROGRAM=extproc)))
Is PROGRAM=extproc the right choice? There are a couple of other programs to pick. I couldn't even start the listener with lsnrctl because it could not "verify the user" or something. Ironically, the listener-setup and database link to a MS SQL server work smoothly.
Now despite lacking some vital information about the CRM DB system, one can still connect to the DB in SQL Developer. Shouldn't it also be possible to make a connection between two Oracle DBs? Please help me with the setup and the creation of the database link.
----- EDIT: --------
Alex Poole's hint helped me get it to work. I used
show parameters service_names;
to get the full service name. It has the form abc.def, with def being the domain. Thusly, I added the domain name to the TNS alias in tnsnames.ora:
MYTNSENTRY =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.1.2.3)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = abc.def)
)
)
The connection can be tested with tnsping MYTNSENTRY on the command prompt of the target DB server. The tnsnames.ora is local. However, I deleted all changes to the "local" listener.ora, since the listener indeed resides on the CRM server.
The SQL command is mostly unchanged, but now the connection works:
CREATE PUBLIC DATABASE LINK xxx CONNECT TO some_user IDENTIFIED BY ***** USING 'MYTNSENTRY'
You've said the SID is abc, but in your tnsnames.ora you've got the SERVICE_NAME in the CONNECT_DATA section. They are not always the same thing - see this question, or this Ask Tom entry. You haven't actually said what error you're getting, but just changing that to SID = might make a difference.
The listener.ora, and indeed the listener, are on the server that hosts the CRM database, not on the one that hosts your 'target' database. As you can connect from SQL Developer that is apparently already configured. The tnsnames.ora does need to be local.
But if you do know the service_name for the CRM database you can skip that and use the EZCONNECT syntax to define everything in the link:
CREATE PUBLIC DATABASE LINK xxx
CONNECT TO non-sys IDENTIFIED BY *****
USING '//172.1.2.3:1521/service_name';
Check your SQL Developer configuration to see if that is already using the service name, rather than SID, and if not you'll need to discover it. If you had access to the CRM server you could use lsnrctl to find the service names that are registered, but as you don't seem to you will need to connect to the database and run show parameters service_names or select value from v$parameter where name = 'service_names';.
You need more privileges to create a public link than a private one, and public is potentially less secure as it exposes your CRM database to anyone on your target one. So I'd only make it public if really needed, and either way connect to a read-only account if you're able to create one.
Also note that if your target database has global_names set to true the database link name has to match the remote service name.
Not only should you NOT connect as SYS unless necessary, you CANNOT connect as SYS over a database link.

Resources