How do create ODBC data source by using oracle instant client? - database

As I knew, Oracle Instant Client is free from OTN for anyone to use in a development or production environment. But in order to create a ODBC data source on windows, i need a tns service name? How can I create odbc data source on windows os by using oracle instant client?

Check the ODBC installation instructions http://www.oracle.com/technetwork/database/features/oci/odbc-ic-releasenotes-094306.html :
On Windows
Install the Instant Client Basic or Basic Light package.
Download the Instant Client ODBC package. Unzip it
in the same directory as your Basic or Basic Light package.
Execute
odbc_install.exe from the Instant Client directory. If Instant
Client is 11g or lower, start the command prompt with the
Administrator privilege.
On Linux I sometimes hand edit my .odbc.ini file to change the TNS connect string in the ServerName field, for example to set it with the 'Easy Connect' TNS syntax:
ServerName = localhost/orclpdb

Related

Connect to linked server (Oracle) in SQL Server using Instant Client

I need to connect to a remote database (Oracle) using a MS SQL Server (2019) linked server. What I did so far:
Installed Oracle Instant Client x64 and the ODBC drivers on the machine where the SQL server is running
Created a symlink to the central TNSNAMES.ORA (on a file share in the network) inside the Oracle Instant client folder.
Set the necessary environment variables
Created an ODBC connection to the database on the Oracle server on this machine
Restarted MS SQL Server
Created a linked server (Microsoft OLEDB Provider for ODBC Drivers) in the SQL instance
When connecting to the SQL Server using sqlcmd on this machine (I did not install SSMS there), I can query the linked database using OPENQUERY(). I can also read the file TNSNAMES.ORA using this command (note, the given file is the symlink, but it displays the contents of the linked file, as it should):
SELECT * FROM OPENROWSET(BULK 'C:\InstantClientx64\tnsnames.ora', SINGLE_CLOB) TNSNames
So far, everything is fine.
Now, when I connect to the SQL Server from my workstation using SSMS, i get the following error when trying to read TNSNAMES.ORA using the command above:
Cannot bulk load because the file "C:\InstantClientx64\tnsnames.ora" could not be opened. Operating system error code 5(Access is denied.).
I created a file test.txt in the instant client folder containing something like "Am I allowed to read this?" - and I was, no problems.
I started procmon on the server to find out what happens. When using the above command on the SQL server, I get a REPARSE (because it's a link!), and then SUCCESS, the file is displayed in the sqlcmd console.
When using this command in SSMS (on my local workstation), first appears the REPARSE (OK), then ACCESS DENIED.
In both cases it is the same user account which is displayed as "Impersonating" in the procmon's details. There is definitely no problem with a firewall, and the read permissions on the tnsnames.ora file on the network share are granted for Everyone. I am also able to create an ODBC item on the local workstation, and can connect and query the database from here.
I have done this in the past I don't know how often, and never had problems. What am I missing?
Why are you trying to read the tnsnames.ora file via SQL? The Oracle libraries will (should) internally open it and use it when your app connects to the DB.
The default location for network config files is shown in the Instant Client installation doc. In your case it will be C:\InstantClientx64\network\admin. Unless you have set the TNS_ADMIN variable, then start by creating this subdirectory and putting tnsnames.ora in it.
(A future version of Instant Client on Windows will create the network\admin subdirectory automatically, similar to the way it is created with the Linux Instant Client packages).

Oracle database connects via sqlplus but listener isnt running on my Ubuntu

On my windows laptop, i installed oracle Virtual machine and installed Ubuntu 18.04. And then i installed oracle 11g so I can practice writing shell scripts that update oracle database.
I can easily connect to database using sqlplus and create tables etc..
However when i wrote a simple script to connect to database and perform a simple task my script never connects to oracle database.
Also i checked that the listener is not running and when i check the current status I get the below error:
TNS-12541: TNS: No Listener
TNS-12560: TNS: Protocol adapter error
TNS-00511: No Listener
Linux Error: 111: Connection refused
I am new to everything please can anyone help me?

Use the TDS Remoting feature of the CData ODBC Driver for mongodb to set up a linked server for MongoDB data

I installed the CData ODBC Driver for MongoDB to make the application that can access SQL Server connect to mongodb.
According to the official document,I have configured the system DSN.
Then I modified the config file 'CData.ODBC.MongoDB.Remoting.ini' config file screenshot:-
,in which the users and passwords was the same as what I typed in DSN.
I started CData.ODBC.MongoDB.Remoting.exe and the console printed
Test connection successful. CData ODBC Driver For MongoDB 2015
remoting server starts.Local port :3309.
But when I created a linked server from SQL Server Management Studio linked server info
,it showed that the user 'noobwulei' login failed.
I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this.
Based on the console output, looks like the remoting service isn't running on the expected port:
... Local port :3309.
According to the Help documentation (http://cdn.cdata.com/help/DGB/odbc/pg_cli.htm) the executable runs the MySQL daemon by default.
In order to run the TDS daemon, you will need to run the executable from the command line and pass TDS as the protocol option (-t):
\> CData.ODBC.MongoDB.Remoting.exe -t TDS

NodeJS: How to connect to MSQL database using Windows Authentication/trustedConnection from Mac

I'm building a NodeJS app on my Mac and I need to connect to a MSSQL database.
Using the node module mssql, I'm able to connect to the server. But authentication fails because the database server requires the use of Windows Authorization or 'trustedConnection'. If I could use the Microsoft Driver for Node.js for SQL Server with mssql, I could provide a true value for 'options.trustedConnection', but that driver is Windows only.
Is there any way to do what I'm attempting? I don't see a way with the other drivers/node modules (tedious, tds, etc) to provide a connection string that would set trustedConnection to true or use Windows Authentication.
I just successfully connected to the SQL Server from Ubuntu 14.04.
I use FreeTDS as the driver, and unxiODBC as the driver manager, node odbc as the Node.js module to connect. I think this might be used on OSX as well.
More information can see this link. I blog it, and hope can save someone else's time.
But I need to do more research because I want to use this node module mssql to connect. mssql uses tds or tedious as drivers.

Cross Server script execution oracle

I am having DB server on another machine and having asp.net application installed on local machine.
I want to connect remote DB and execute my scripts, since my local machine doesn't have oracle installed
I have go-ogled and tried few links it tells me editing transnames.ora file adding one new entry
But this will not work since my local machine doesnt contain sqlplus
So I would like to now what are the tools I will need to download on local application server to run my scripts.
You need to install oracle driver to communicate with remote server.
There are multiply options:
This 2 will have tnsnames.ora file that you we told about:
Full oracle client
Oracle instant client (small in size)
Tool specific:
oracle jdbc driver for java
cx_oracle for python
something else for other tool
OS specific:
on windows you can setup an ODBC driver to connect to ORACLE
Thanks abhi, filename is corrected.
After installing a client, you need to know where is your database server.
In simple situation you need host, port and sid.
entries in tnsnames.ora look like this:
connectionName =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = yourHost)
(Port = yourPort)
)
)
(CONNECT_DATA =
(SID = yourSID)
)
)
You fill in all information and save the file.
after that you can check connection ( I don't know, if tnsping is shipped with instant client)
>tnsping connectionName
OK (description of a connection)
Useful tip: you can just go to remote server (or some other PC that have db access already configured) and tnsping some connection (you probably already have a standard name for it).
than just grap the output in brackets and put it into your tnsnames.ora.
your connection string:
username/password#connectionname
btw, instead of conenctionname you could put the whole connection descriptions (from tnsnames.ora)
username/password#(description=...)
Now you can use the Oracle Managed Driver which does not require the installation of the Oracle Client on the machine. This is extremely helpful as Oracle Client installations are painful. It requires nothing more than putting the driver in your bin directory and providing an appropriate connection string and provider name.
To install the managed driver via NuGet run...
Install-Package odp.net.managed
You may need to change the provider name (I believe it's Oracle.ManagedDataAccess off the top of my head).
Example connection string...(replace MyHost, MyPort (usually 1521), MyOracleSid, myUsername, and myPassword with appropriate info).
SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=MyHost)(PORT=MyPort))(CONNECT_DATA=(SERVICE_NAME=MyOracleSID)));
uid=myUsername;pwd=myPassword;

Resources