How to configure Oracle to be able to query a MS Access database (.accdb) that is lcoated in the same server (localhost)?
Which steps to follow?
Version of Oracle: 11g -> 11.2.0.1.0
Version of Windows: Windows Server 2008
Steps to complete:
Create System DSN with Microsoft Access Driver
Modify listener.ora file
Create the file initaccess.ora
Modify tnsnames.ora file
Restart listener
Check connection with access database
Create the DB Link in Oracle
STEP 1: Create system DSN
First go to ODBC Data Source Administrator click on System DSN tab. The create a DSN with the following parameter (you can choose the name link that you prefer but then you need to keep the same name all over the process).
In our case:
Driver: Microsoft Access Driver (*.mdb,*.accdb)
Name: access
Description: (doesn't matter)
Database -> Select -> (Select the .accdb or .mdb database)
Save the configuration
Make sure you see this listed once you save it:
Name - Driver
access - Microsoft Access Driver (*.mdb,*.accdb)
STEP 2: Modify listener.ora file
Let's locate the file. In our case:
E:\app\Administrador\product\11.2.0\dbhome_1\NETWORK\ADMIN
We need to add the following text at the end. By the way, look at I posted as 'oracle_home' the directory in C: drive. That's because I had more than one directory related to Oracle, and I still don't understand it but worked in my case. Maybe in yours there's only one.
Parameters you need to modify:
In first block:
SID_NAME: name chosen in the step above. The name of the dsn created ('access' in our case)
ORACLE_HOME: Home directory of Oracle
PROGRAM = dg4odbc (I think that from Oracle 11g and beyond, 'dg4odbc' is mandatory.
In second block:
HOST: The name of the hostname (not sure if localhost' or an IP address are supported, but I guess they are)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC=
(SID_NAME = access)
(ORACLE_HOME = C:\app\Administrador\product\11.2.0\dbhome_1)
(PROGRAM = dg4odbc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host_name)(PORT = 1521))
)
)
Make sure there is no space before 'SID_LIST_LISTENER' or 'LISTENER' in the file you modify:
STEP 3: Create the initaccess.ora file
Go to:
E:\app\Administrador\product\11.2.0\dbhome_1\hs\admin
There, make a copy of 'initdg4odbc.ora' file (I deleted it after I made a copy). Add the following text to the file:
HS_FDS_CONNECT_INFO = access
HS_FDS_TRACE_LEVEL = 0
HS_FDS_CONNECT_INFO: Here we write the name of the link created in the ODBC source tool in the first step, so it's 'access'
HS_FDS_TRACE_LEVEL: Leave it with a 0
STEP 4: Modify tnsnames.ora file:
Let's locate the file. In our case:
E:\app\Administrador\product\11.2.0\dbhome_1\NETWORK\ADMIN
Parameters to modify:
HOST: hostname of the server
SID: this is the name of the 'initaccess.ora' file BUT taking away the 'init' part and '.ora' file extension: then 'access'.
(HS=OK) = don't forget this.
access =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = host_name) (PORT = 1521))
(CONNECT_DATA =
(SID = access)
)
(HS=OK)
)
Be sure that you don't leave spaces before the 'access =' parameter.
STEP 5: Restart the listener
Open a command line terminal
Go to: C:\app\Administrador\product\11.2.0\dbhome_1\BIN
Stop the listener
C:\app\Administrador\product\11.2.0\dbhome_1\BIN>LSNRCTL.EXE stop
You should see a message saying it was successfull
Restart the listener
C:\app\Administrador\product\11.2.0\dbhome_1\BIN>LSNRCTL.EXE start
You should see a message saying it was successfull
You should also see, (in the output, when restarting the server) a message talking about the 'access' service we just added
El servicio "access" tiene 1 instancia(s).
La instancia "access", con estado UNKNOWN, tiene 1 manejador(es) para este ser
vicio...
El comando ha terminado correctamente
STEP 6: Test connection with the access database
Open a command line terminal
Go to: C:\app\Administrador\product\11.2.0\dbhome_1\BIN
Run tnsping.exe (as argument, pass the name of the link: 'access'):
C:\app\Administrador\product\11.2.0\dbhome_1\BIN>tnsping.exe access
You should see a message saying it was correctly run and displaying the delay in msecs
TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 06-JUN-2
014 11:04:35
Copyright (c) 1997, 2010, Oracle. All rights reserved.
Archivos de parßmetros utilizados:
E:\app\Administrador\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
Adaptador TNSNAMES utilizado para resolver el alias
Intentando contactar con (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = CUPCA
KE) (PORT = 1521)) (CONNECT_DATA = (SID = access)) (HS=OK))
Realizado correctamente (20 mseg)
STEP 7: Create the DB Link in Oracle and query the Ms Access database:
Create the DB Link (always as **sys):**
CREATE public DATABASE LINK accessdblink USING 'access';
* 'access': Same name as in tnsnames.ora -> 'access = '
Query the database:
SELECT * FROM table_name#accessdblink;
Related
I am developing a Spark Streaming application which would listen to a folder (partitioned as yyyyMMdd) and aggregate the number of records written per minutes then persist the results to an Oracle table.
I have developed a JDBCSink (ForeachWriter) and in the open method I'm trying to open a connection to Oracle but I am getting "oracle.net.ns.NetException: could not resolve the connect identifier" exception while creating the Oracle connection. I am using Oracle wallet (SSO) and I'm able to connect over sqlplus using this wallet by setting TNS_ADMIN environment variable.
I am pushing the tnsnames.ora, sqlnet.ora, cwallet.sso and ewallet.p12 with the spark-submit --files option, and I have verified the files are pushed to the executors with the SparkFiles.get method in the sink class. I have also added third party Oracle dependencies for Oracle wallet with spark-submit --jars option (namely ojdbc7.jar,oraclepki.jar,osdt_cert.jar,osdt_core.jar)
The code piece for opening the connection is as follows:
Class.forName("oracle.jdbc.driver.OracleDriver")
System.setProperty("oracle.net.tns_admin", new Path(SparkFiles.get("tnsnames.ora")).getParent.getName)
val ds = new OracleDataSource()
val props = new Properties()
props.setProperty(OracleConnection.CONNECTION_PROPERTY_WALLET_LOCATION,
new Path(SparkFiles.get("cwallet.sso")).getParent.getName)
ds.setConnectionProperties(props)
ds.setURL("jdbc:oracle:thin:#xe")
I have tried to isolate the problem
The Oracle version is 12.1.0.2 (I am using a Docker image)
spark-submit2 ^
--master local ^
--files "%CWD%\wlt\tnsnames.ora,%CWD%\wlt\sqlnet.ora,%CWD%\wlt\cwallet.sso,%CWD%\wlt\ewallet.p12" ^
--jars "%CWD%\lib\ojdbc7.jar,%CWD%\lib\oraclepki.jar,%CWD%\lib\osdt_cert.jar,%CWD%\lib\osdt_core.jar" ^
--class OJDBCSinkMain ^
.\target\spark-streaming-ojdbc-sink-1.0-SNAPSHOT-jar-with-dependencies.jar
My sqlnet.ora file is as follows:
NAMES.DIRECTORY_PATH=(TNSNAMES, EZCONNECT)
SQLNET.WALLET_OVERRIDE=TRUE
SSL_CLIENT_AUTHENTICATION=FALSE
SSL_VERSION=0
and my tnsnames.ora file is:
xe =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = xe)
)
)
I also verified the credentials for Oracle service xe exists in my wallet:
comment mkstore -wrl . -listCredential
List credential (index: connect_string username)
1: xe system
Do you have any comments? Thanks in advance.
My mistake, I needed a rubber dock to spot!!! SparkFiles.get("tnsnames.ora")).getParent.getName returns relative path, not the absolute. My problem is solved now.
Whenever I try to login or connect into SQL command line or SQL*Plus (11g Standard Edition Win64) I get an error
ORA-12154: TNS:could not resolve the connect identifier specified.
I have tried to solve this problem with google help but I can't.
so please help me out of this!
You are trying to connect to a database v. "v" is the connect identifier. However, your Oracle client does not know of v. This is what the error message is trying to tell you.
Try
c:>tnsping v
Hopefully this will give you something like this:
C:\Users\rwe>tnsping v
TNS Ping Utility for 64-bit Windows: Version 12.2.0.1.0 - Production on 21-MAR-2018 15:49:51
Copyright (c) 1997, 2016, Oracle. All rights reserved.
Used parameter files:
C:\app\rwe\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
TNS-03505: Failed to resolve name
What you can extract from this is the location:
C:\app\rwe\product\11.2.0\dbhome_1\network\admin\
This is where your tnsnames.ora file resides. Edit this file and add the correct information for your database v. Substitute servername for the machine your Oracle database is on.
V =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = tcp)(HOST = servername)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = V)
)
)
I just installed Oracle 11g on my work dev computer which has Windows 7 64-bit and is on a network with a domain set up. When I try to connect to the "XE" database/SID using SQL Developer I get the following errors list below.
Any ideas?
I've researched online and tried a number of the solutions suggested and cannot get it to work. I can confirm the following:
The database is started. I can connect using SQL Plus.
Both the OracleServiceXE and OracleXETNSListener services are started
Internet Information Systems (IIS) is installed and working properly.
In addition to not being able to connect with SQL Developer, when I the the "Get Started" web application, it doesn't work.
When I first tried to connect, the settings in SQL Developer were as follows:
Hostname: localhost
Port: 1521
SID: xe
However, I got the following error:
Status : Failure -Test failed: Listener refused the connection with the following error: ORA-12505
After researching I found that I should look at the listener end points (whatever that means) in the "listner.ora" file and confirm the hostname. That file has the following:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = C:\Oracle\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\Oracle\oraclexe\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = mycomputername.abc.de.mycompany.com.)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
When I saw that the host name was different I first tried changing "HOST" in the listener.ora file from "mycomputername.abc.de.mycompany.com." to "localhost" and then to "127.0.0.1" (note the previous really has an extra period at the end). After doing that, I still got the same error message.
Then, I put everything back the way it was in the "listener.ora" file and instead went to SQL Developer and changed my login information to the following:
Hostname: mycomputername.abc.de.mycompany.com. (again... there really is a period at the end)
Port: 1521
SID: xe
I even tried it with just "mycomputername". Again, I got the error message:
Status : Failure -Test failed: Listener refused the connection with the following error: ORA-12505
I found help from a friend of a friend. Here's what he did.
First, note that he left the settings in the "listener.ora" file alone. Instead he did the following... all from the command prompt.
Step 1: Run SQL Plus directly from the command prompt as the "sysdba" to simulate SQL Plus within the command prompt.
C:\windows\system32>sqlplus / as sysdba
Step 2: Enter the following SQL Plus command to verify the database name (aka global name or SID). The return value was "XE".
SQL> select * from global_name;
Step 3: Enter the following SQL Plus command to set the listner to use the 'localhost' as the "HOST". Apparently, the listener this will override the settings in the "listner.ora" file. I think he said this is saved in the database somewhere and is not saved in a file.
SQL> alter system set LOCAL_LISTENER='(DESCRIPTION_LIST = (DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)
(HOST = localhost)(PORT = 1521))))';
Step 4: Enter the following SQL Plus command to register what you set in step 3 above.
SQL> alter system register;
Step 5: Exit the SQL plus simulation in the command prompt.
SQL> exit
I have installed Oracle 11g Express Edition from http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index-083047.html and also installed SQL Developer, but when I try connect to Oracle Database from Developer (I try create new connection) next error appears:
Ora00604 error occurred at recursive level 1 ORA - 12705.
What should I enter at: Hostname, port and SID
TNSNAMES provided below:
XE = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = DYedilkhan-ПК)(PORT = 1521))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = XE)))
Add this rows into ..\sqldeveloper\ide\bin\ide.conf file
AddVMOption -Duser.language=en
AddVMOption -Duser.region=us
It's working for me.
if you don't know what language and region to use, you can add
AddVMOption -Duser.region=
(nothing after =)
It worked in my case as macloving solution did too
Solved by changing system language. In my case the problem occurred because Windows decided to change my "display language" to English(Kenyan), and unsurprisingly it wasn't supported by the Database.
I have this message while installing ORACLE 11g Release1 on Windows 7 64bit
before Installing the Oracle DB I created the "Microsoft LoopBack Adapter" & set the adapter to be the first order
Checking Network Configuration requirements ...
Check complete. The overall result of this check is: Failed <<<<
Problem: The install has detected that the primary IP address of the
system is DHCP-assigned.
Recommendation: Oracle supports installations on systems with
DHCP-assigned IP addresses; However, before you can do this, you must
configure the Microsoft LoopBack Adapter to be the primary network
adapter on the system. See the Installation Guide for more details on
installing the software on systems configured with DHCP.
And After the installation done I tried to test the connection using SQL Plus I faced this error
-- This is the tnsnames.ora contants
# tnsnames.ora Network Configuration File: E:\ORACLE\Oracle_Base\product\11.1.0\db_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
MTAHAPC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = MTahaPC.lan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = MTAHAPC)
)
)
-- this is the listener.ora
# listener.ora Network Configuration File: E:\ORACLE\Oracle_Base\product\11.1.0\db_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = MTahaPC.lan)(PORT = 1521))
)
)
Sorry, this is the first trail to install Oracle DB, and I get tired from it
That's a warning indicating that your system has DHCP allocation of IPs. This isn't strictly supported because when the service lookup happens, the TNSNAMES.ora file will have an entry for an IP which may or may not correspond to your system since DHCP would mean the IP may be assigned to other computers when the lease is up.
You can choose to ignore this by clicking on the checkbox next to it to indicate that you want to skip the test.