Oracle Database Link to MS Access
In this post, I describe how you can make an Oracle database link to an MS Access database.
When done, you can query from an oracle database onto an Access database.
But with some little changes, you can do the same trick to a SQL Server database or even a
database type you like (to which you can connect by ODBC).
Important: The init-parameter GLOBAL_NAMES should have value FALSE. Check this parameter first
before continuing the procedure.
In this example, I uses TESTDB as database name, replace this with your database/name/user id.
If I mention %oracle_home%, I mean the Oracle Home directory.
This example is worked out on an Oracle 8.1.7.4 installation,
but I suppose it will work on higher Oracle versions too.
1. Open the file inithsodbc.ora (%oracle_home%/hs/admin) and save this as initTESTDB.ora. Edit the content so it looks like:
2. Open the file listener.ora (%oracle_home%/network/admin) and add the following text, save and close the file:
3. Open the file tnsnames.ora (%oracle_home%/network/admin) and add the following text, save and close the file:
4. Check the file sqlnet.ora (%oracle_home%/network/admin) if the following setting is correct (correct if it differs):
5. Start the new TESTDB listener with the following command (on the command line tool):
Starting the new listener can produce an error message, because the services uses the default logon settings (system account).
6. Configure the ListenerTestDb:
If the test succeeded, the database link in Oracle can be made.
1. Create database link to TESTDB (note: credentials SYSTEM/MANGER can be changed to your configuration):
2. Test the link with a count(*) query to a table on the TESTDB database.
If you got a number of rows back, you're done!
When done, you can query from an oracle database onto an Access database.
But with some little changes, you can do the same trick to a SQL Server database or even a
database type you like (to which you can connect by ODBC).
Important: The init-parameter GLOBAL_NAMES should have value FALSE. Check this parameter first
before continuing the procedure.
In this example, I uses TESTDB as database name, replace this with your database/name/user id.
If I mention %oracle_home%, I mean the Oracle Home directory.
This example is worked out on an Oracle 8.1.7.4 installation,
but I suppose it will work on higher Oracle versions too.
1. Create a new ODBC link
- On the Oracle server start the ODBC Data Source Administrator. This can be done by using the run command: go to start/run and type odbcad32 and press enter.
- In the ODBC Data Source Administrator window go to the System DSN tab and click on Add...
- Choose in the Create New Data Source window the Microsoft Access Driver (*.mdb) and click on Finish.
- In the ODBC Microsoft Access Setup window enter the data source name (e.g. TESTDB), the description (e.g. Test database) and select the Access database
- If the Access database is on the same machine as Oracle is running, you can ignore step 1.5 and step 2!
- If the Access database is on another machine in the network, you should use UNC-path notation. In the Map Network Drive window, leave the drive-letter on (none) and select via the UNC-path the Access database. Finish the creation of the ODBC Link and close all the ODBC windows.
2. Create Network ID
In order to perform a good connection to the Access database on another machine, you need to follow the following steps:- Create on the network an user id (e.g. TestDbAdmin) and give this UID read rights on the location of the Access files. NOTE: use the appropriate rights, this depends on the actions you want to take on the Access database.
- Place this user, TestDbAdmin, in the ORA_DBA group on the Oracle server.
3. Create the Oracle TestDb listener
In these steps, some Oracle files will be created and/or modified. A new listener will be created, which will take care of the connection1. Open the file inithsodbc.ora (%oracle_home%/hs/admin) and save this as initTESTDB.ora. Edit the content so it looks like:
01.
# This is a sample agent init file that contains the HS parameters that
02.
# are needed for an ODBC Agent.
03.
#
04.
# HS init parameters
05.
#
06.
HS_FDS_CONNECT_INFO = HORSODBC
07.
HS_FDS_TRACE_LEVEL = OFF
08.
#
09.
# Environment variables required for the non-Oracle system
10.
#
11.
#set <envvar>=<value>
2. Open the file listener.ora (%oracle_home%/network/admin) and add the following text, save and close the file:
01.
LISTENERTESTDB =
02.
(ADDRESS_LIST=
03.
(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1522))
04.
(ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY))
05.
)
06.
SID_LIST_LISTENERTESTDB=
07.
(SID_LIST=
08.
(SID_DESC=
09.
(SID_NAME=TESTDB)
10.
(ORACLE_HOME = C:\oracle\ora81)
11.
(PROGRAM=hsodbc)
12.
)
13.
)
3. Open the file tnsnames.ora (%oracle_home%/network/admin) and add the following text, save and close the file:
1.
TESTDB =
2.
(DESCRIPTION =
3.
(ADDRESS = (PROTOCOL = tcp)(HOST = localhost)(PORT = 1522))
4.
(CONNECT_DATA =
5.
(SID = TESTDB)
6.
)
7.
(HS = OK)
8.
)
4. Check the file sqlnet.ora (%oracle_home%/network/admin) if the following setting is correct (correct if it differs):
1.
SQLNET.AUTHENTICATION_SERVICES= (NONE)
5. Start the new TESTDB listener with the following command (on the command line tool):
Orahome\bin\lsnrctl start listenerTestDb
NOTE: DON'T USE A RDP (REMOTE DESKTOP) CONNECTION! Because of windows credential error. Apply this directly on the Oracle machine or via e.g. VNC Viewer connection.
Starting the new listener can produce an error message, because the services uses the default logon settings (system account).
6. Configure the ListenerTestDb:
- Open the properties panel of this service (can be found in the windows services list at the administrative tools)
- Stop the service (if it is running) and edit the log on credentials to the user account earlier made (e.g. TestDbAdmin)
- (Re)start the service.
1.
%oracle_home%\bin\tnsping testdb
If the test succeeded, the database link in Oracle can be made.
4. Create Oracle Database Link to TestDb
1. Create database link to TESTDB (note: credentials SYSTEM/MANGER can be changed to your configuration):
1.
CREATE
PUBLIC
DATABASE
LINK “TESTDB”
2.
CONNECT
TO
"SYSTEM"
3.
IDENTIFIED
BY
"MANAGER"
4.
USING
'TESTDB'
2. Test the link with a count(*) query to a table on the TESTDB database.
If you got a number of rows back, you're done!
No comments:
Post a Comment