Load data to remote DB using sqlldr - oracle

I wanted to load data to remote db using sqlldr.I did it using following command
>sqlldr GANUKA/GANUKA#jdbc:oracle:thin:#172.21.0.180:1521:orcl control=D:\Work\CLSTMAS.ctl
log=D:\Work\CLSTMAS.log
But it gives the following error.
SQL*Loader-704: Internal error: ulconnect: OCIServerAttach [0]
ORA-12154: TNS:could not resolve the connect identifier specified
Need a help

You're mixing up two different worlds here. One is the OCI world where sqlldr lives. It expects Oracle instance names defined in TNSNAMES.ORA (or a similar service). The other world is the JDBC world that uses connection identifiers with words like "jdbc" or "thin".
So you have two options:
If your environment has a proper TNS setup, you have to change the command line to something like sqlldr GANUKA/GANUKA#MONTY.CORP control=...
If not, you can use an Easy Connect string: sqlldr GANUKA/GANUKA#//172.21.0.180:1521/orcl control=...

I ended up having to use a thin client connection string. I couldn't get #Codo 's solution to work.
sqlldr \'username/passwd#(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=myhost.com)(PORT=1111)))(CONNECT_DATA=(SID=MYSIDE)(SERVER=DEDICATED)))\' control=loader.ctl data=data.csv

Related

Oracle cannot get sqlldr to reach listener, get ORA-12514 error

Every time I try to run the following sqlldr command on a terminal only oracle 19c system:
sqlldr username/password#$HOSTNAME/$ORACLE_SID control=rules.ctl log=backup_error_logs.txt data=output.csv errors=1000000
I get the following error message:
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
Things I have tried:
Verified that the listener is operable and listener.ora file is properly formatted with lsnrctl.
Verified the connection and oracle environment variables are working as the following sqlplus command runs without problem:
sqlplus username/password#$HOSTNAME/$ORACLE_SID
Verified the tnsname.ora is running properly configured with the following tnsping command:
tnsping $ORACLE_SID
Cannot think of anything else to try or to check. Does anyone have any advice without resorting to the GUI tools?
Could be a problem of quotes in the variables, the behavior of both tools is different regarding quotes.

SQL script through bat file

I am trying to automatize some daily checks and now I need to use SQL query.
So I write my SQL script and then tried to run it through batch file to be able to put it to task scheduler.
So I wrote something like this
sqlplus user/pw#DBServer #PathToSQLScript.sql > "DestinationWhereToPutOutput"
It is confusing me because this works normally at any other server that I already automatized but at this one it gave me error
ORA-12154: TNS: could not resolve the connect identifier specified
And wanting me to reenter credentials.
Is there any other way how to run SQL script through batch file?
Thanks in advance for any advice.
The most frequent reason for ORA-12154 is that DBServer can't be found in TNSNAMES.ORA file. Therefore:
create DBServer's alias in TNSNAMES.ORA, or
use EZCONNECT syntax (which doesn't require TNSNAMES.ORA) that looks like host:port/service_name
For example, that would be
sqlplus user/pw#db_server:1521/orcl
For much more info about troubleshooting ORA-12154, see Ed Stevens' blog

I am able to connect to Oracle Db using Toad but connection using sqlplus is not working. Getting TNS timeout error

I am able to connect to Oracle DB using Toad with Datasource name and username/password. Oracle client 12 as Oracle driver. oracle database path is set properly in the environment variables. sqlnet.ora, listener.ora and tnsnames.ora is present in ORACLE\ORANT\NETWORK\ADMIN folder and configured properly. I tried to query using Sqlplus in cmd prompt using following command:
connect User/pass#dw-prod.server.int:1527/pdw1s_servicename
I am getting ORA-12170: TNS Connect timeout error. Please help.
In SQL*Plus, just need to connect using the TNS alias.
connect user/password#tns_alias
If your password contains specific characters like # or ! probably you are getting the error for this

Cannot connect to database using TOAD?

I get a error while trying to connect using TOAD:
ora 12154 tns could not resolve the connect identifier specified(myDBname)
You might be mis-naming the server...
If you are using local naming (TNSNAMES.ORA file):
Make sure that "TNSNAMES" is listed as one of the values of the NAMES.DIRECTORY_PATH parameter in the Oracle Net profile (SQLNET.ORA)
Verify that a TNSNAMES.ORA file exists and is in the proper directory and is accessible.
Check that the net service name used as the connect identifier exists in the TNSNAMES.ORA file.
Make sure there are no syntax errors anywhere in the TNSNAMES.ORA file. Look for unmatched parentheses or stray characters. Errors in a TNSNAMES.ORA file may make it unusable.
Try using the IP(rather then the name) of the Oracle serverin tnsnames.ora, and check you have permissions. Can you ping the server?

how can I use "impdp" command importing .dmp data with port number?

I am trying to import data to an Oracle database. I have ".imp" and ".dmp" files for importing data. The database is using port 1521 and database name is "DB".
I have tried the following command, but doesn't work.
impdp root/password#xxx.xxx.xxx.xxx:1521:DB
dumpfile=transmart.dmp
logfile=transmart.imp
schemas=i2b2hive,i2b2metadata,i2b2sampledata,i2b2demodata,i2b2workdata
,biomart,biomart_user,deapp,searchapp,tm_cz,tm_lz,tm_wz
ERROR: either ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA or ORA-12545: Connect failed because target host or object does not exist
I can telnet the IP and port with no problem.
Can anyone suggest please?
Thanks!
You have a syntax error in your EZConnect string.
Try this instead (no need to fuss with tnsnames.ora this way):
impdp root/password#xxx.xxx.xxx.xxx:1521/DB
Notice the replacement of the ":" with a "/" between port and service name.
As a side note, I long ago got out of the habit of putting passwords in command lines, where they may be easily snooped while the command is running. Let the program prompt you for the password:
impdp root#xxx.xxx.xxx.xxx:1521/DB
Especially if you're going to use root for your commands ;-)
Your reference to telnet suggests you are running this from a remote client rather than locally on the database server.
You need to edit your client's TNSNAMES.ORA file with the location information for DB. Perhaps you think you've already done this, in which case you've probably introduced a typo or got the syntax wrong.
The other thing to check is that the listener is running on the database server, as that's a very common cause of ORA-12545.
to import the latest transmart database dump we used the following:
wget https://github.com/transmart/transmartApp-DB/zipball/master
unzip master
tar zxvf transmart.dmp.tar.gz
cp transmart.dump /u01/app/oracle/admin/XE/dpdump
chown oracle:dba /u01/app/oracle/admin/XE/dpdump/transmart.dmp
impdp SYSTEM dumpfile=transmart.dmp logfile=transmart3.log full=y
If you don't use the full=y you will end up missing a number of tables. Hope this is still useful to you or someone else.

Resources