How to setup Oracle using SSL and JDBC - oracle

I am struck configuring Oracle SSL. Could someone tell me the detailed steps to update the configuration and how to use in JDBC?
Refer to https://docs.oracle.com/cd/E12517_01/back_office/pdf/141/html/pos_sg/appendix_jdbc_oracle.htm#CHDBAFEC
What I have done is
generate the wallet and export the keystore
orapki wallet create -wallet E:\app\wallet -pwd core#123 -auto_login
orapki wallet add -wallet E:\app\wallet -pwd core#123 -dn "CN=localhost, OU=Example Department, O=Example Company, L=Birmingham, ST=West Midlands, C=GB" -keysize 1024 -self_signed -validity 365
orapki wallet pkcs12_to_jks -wallet E:\app\wallet -pwd core#123 -jksKeyStoreLoc E:\app\wallet\oracle_ks.jks -jksKeyStorepwd core#123 -jksTrustStoreLoc E:\app\wallet\oracle_ts.jks -jksTrustStorepwd core#123
Update the oracle_home/network/admin
2.1 listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = CBX-PF217JHT-E490)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCPS)(HOST = CBX-PF217JHT-E490)(PORT = 2484))
)
)
ADR_BASE_LISTENER = E:\app\virtual
SSL_CLIENT_AUTHENTICATION = FALSE
WALLET_LOCATION =
(SOURCE =
(METHOD = FILE)
(METHOD_DATA =
(DIRECTORY = E:\app\wallet)
)
)
2.2 sqlnet.ora
SQLNET.AUTHENTICATION_SERVICES= (BEQ, TCPS)
SSL_VERSION = 3.0
SSL_CLIENT_AUTHENTICATION = FALSE
WALLET_LOCATION =
(SOURCE =
(METHOD = FILE)
(METHOD_DATA =
(DIRECTORY = E:\app\wallet)
)
)
DIAG_ADR_ENABLED = OFF
2.3 tnsnames.ora
LISTENER_ORCL =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = CBX-PF217JHT-E490)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCPS)(HOST = CBX-PF217JHT-E490)(PORT = 2484))
)
)
ORCL =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = CBX-PF217JHT-E490)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCPS)(HOST = CBX-PF217JHT-E490)(PORT = 2484))
(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = orcl))
)
)
Update DataSource url to be
jdbc:oracle:thin:#(DESCRIPTION= (ADDRESS= (PROTOCOL=tcps) (HOST=localhost) (PORT=2484) ) (CONNECT_DATA= (SERVICE_NAME=orcl))
Whith startup of Tomcat add such parameter
-Doracle.net.ssl_cipher_suites=TLS_RSA_WITH_RC4_128_SHA,TLS_RSA_WITH_RC4_128_MD5 -Djavax.net.ssl.trustStore="E:\app\wallet\oracle_ts.jks" -Djavax.net.ssl.trustStorePassword="core#123" -Djavax.net.ssl.trustStoreType="JKS" -Djavax.net.ssl.keyStore="E:\app\wallet\oracle_ks.jks" -Djavax.net.ssl.keyStoreType="JKS" -Djavax.net.ssl.keyStorePassword="core#123"
But I still cannot start up with Tomcat. Could someone tell me which step is wrong or what else configuration I should do?
Here is the error log when start up tomcat
Caused by: oracle.net.ns.NetException: NL Exception was generated TNS-04610: No literals left, reached end of NV pair
at oracle.net.resolver.AddrResolution.resolveAddrTree(AddrResolution.java:777)
at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:510)
at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:660)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:286)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1438)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:518)
... 43 more

Can you specify the JDBC version and JDK version that you are using? Did you check the blog for 12.2 and lower? Also, after 18c, you can add all properties into ojdbc.properties file and use it as described in the quickstart guide to ATP.

You're missing a closing parenthesis at the end of your URL:
jdbc:oracle:thin:#(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=localhost) (PORT=2484))(CONNECT_DATA= (SERVICE_NAME=orcl)))

I had the same issue and got the following exception while creating connection from SQL Developer:
NL Exception was generated TNS-04610: No literals left, reached end of NV pair
The problem was with the wrong connection string - one closing bracket was missing:
jdbc:oracle:thin:#(DESCRIPTION= (ADDRESS= (PROTOCOL=tcps) (HOST=localhost) (PORT=2484) ) (CONNECT_DATA= (SERVICE_NAME=orcl)))

Related

Oracle Database 12c Connection

I have already set up an Oracle Database but I am facing a connectivity problem in the below manner:
sqlplus CISADM/CISADM#<IP>:1521/PSRM
sqlplus CISADM#PSRM
With the above two options I successfully connect to the database. Although, when I try to connect as:
sqlplus CISADM#<IP>:1521/PSRM
I get the following error :
ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
I can perform ping either with IP, or hostname, tnsping with IP and hostname successfully.
My tnsnames.ora file:
PSRM =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = <IP>)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PSRM)
)
)
My sqlnet.ora file:
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)
I am connecting from client PC to a Database which is located in a VM. The above files are from client
Files from VM, where Database is hosted:
tnsnames.ora:
PSRM =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <IP>)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = PSRM)
)
)
listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = <IP>)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
Any ideas?
You should run it like this :
sqlplus CISADM#\"<IP>:1521/PSRM\"
Important: The \" in the beginning and end of the server:port/service is part of the syntax.

Unable to connect to a database using sqlplus

I have configurated into my tnsnames.ora my connection string. In my sqlnet.ora my content is as follows:
NAMES.DIRECTORY_PATH= (LDAP, TNSNAMES, HOSTNAME)
NAMES.DEFAULT_DOMAIN = WORLD
TRACE_LEVEL_CLIENT = OFF
SQLNET.EXPIRE_TIME = 30
When I make a tnsping call to a SID from tnsnames.ora I'm gettin the error:
TNS-03505: Failed to resolve name
Sample configuration from tnsname.ora
TNS_NAME =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = HOST.NAME)(PORT = PORT_NUMBER))
)
(CONNECT_DATA =
(SERVICE_NAME = SID)
)
)
What am I doing wrong?
I have used the following connect string without using tnsnames.ora for mappings in order to connect to remote database:
sqlplus username/password#(DESCRIPTION =
(ADDRESS = (PROTOCOL= TCP)(Host= hostname.network)(Port= remote_port))
(CONNECT_DATA = (SID = remote_SID))
)

Error with try to connect oracle db with ruby

I'm trying to connect by ruby to a oracle db, but I've an error:
OCIError: ORA-12514: TNS:el listener no conoce actualmente el servicio solicitado en el descriptor de conexión
oci8.c:659:in oci8lib_240.so
The listener don't know actually the requested service in the connection descriptor.
I downloaded the instant client 12_2 and the odbc to w7 64b and the oci.dll to w7 32b and I put it in the ruby folder.
(http://www.oracle.com/technetwork/topics/winx64soft-089540.html)
I downloaded the db 11g release 2 to w7 64b, and I run the setup. I configurer the listener since NET MANAGER.
(http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html)
I have the sql developer and the connection and the querys works ok.
I configured the tnsnames.ora, listener.ora and sqlnet.ora
tnanames:
SERVICE_PODVCT_ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = podvct.x.com)(PORT = 1521))
)
(CONNECT_DATA =
(SID = PODVCT)
(SERVICE_NAME = PODVCT)
(SID = PODVCT)
)
)
listener:
LISTENER_PODVCT_ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = podvct.x.com)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = PODVCT)
(SID = PODVCT)
)
)
sid_list_LISTENER_PODVCT_ORCL=
(sid_list=
(sid_desc=
(oracle-home=C:\app\user\product\11.2.0\dbhome_1)
(sid_name=PODVCT)))
ADR_BASE_LISTENER_PODVCT_ORCL = C:\app\user
sqlnet:
AMES.TRACE_DIRECTORY = C:\app\user\product\11.2.0\dbhome_1\NETWORK\trace
SQLNET.AUTHENTICATION_SERVICES= (NTS)
NAMES.DIRECTORY_PATH= (TNSNAMES, HOSTNAME)
NAMES.TRACE_FILE = names.trc
NAMESCTL.TRACE_FILE = namesctl.trc
NAMES.PREFERRED_SERVERS =
(address_list =
(address = (protocol = tcp)(host = podvct.x.com)(port = 1521))
)
NAMES.LOG_FILE = names.log
NAMESCTL.TRACE_LEVEL = ADMIN
NAMES.LOG_DIRECTORY = C:\app\user\product\11.2.0\dbhome_1\NETWORK\log
NAMES.DEFAULT_DOMAIN = world
NAMESCTL.TRACE_DIRECTORY = C:\app\user\product\11.2.0\dbhome_1\NETWORK\trace
NAMES.TRACE_LEVEL = ADMIN
ADR_BASE = C:\app\user
I configured the environment variables:
PATH: ...;C:\Ruby24-x64\bin\oci.dll;C:\Oracle_odbc;%ORACLE_HOME%/network/bin;C:\app\PRIVE2\product\11.2.0\dbhome_1\bin;
ORACLE_HOME:C:\app\user\product\11.2.0\dbhome_1
ORACLE_SID:podvct
NLS_LANG: SPANISH_SPAIN.WE8MSWIN1252
TNS_ADMIN: C:\app\USER\product\11.2.0\dbhome_1\NETWORK\ADMIN
And in ruby I put:
require 'dbi'
require 'oci8'
//dbh = OCI8.new(user,password,'podvct.x.com:1521/PODVCT')
dbh = DBI.connect("DBI:OCI8:podvct.x.com:1521/PODVCT",user,password)
I checked the connection since ruby and since sqlplus and the error is:
dbh = DBI.connect("DBI:OCI8:podvct.monsanto.com:1521/PODVCT",user,password)
OCIError: ORA-12514: TNS:el listener no conoce actualmente el servicio solicitado en el descriptor de conexión
oci8.c:659:in oci8lib_240.so
The listener don't know actually the requested service in the connection descriptor.
I try with all and the response is put the ruby sentence like this:
dbh = DBI.connect("DBI:OCI8:SERVICE_PODVCT_ORCL",user,pass)
SERVICE_PODVCT_ORCL is the name of the service in the tnsnames.ora
thanks!

oracle second listener not work

I created two databases one called test and one that is called archivio. The SID is equals to name. I also created a listener for SID test that responds on port 1521 and one for the SID archivio that should answer on port 1522.
I have verified that the services are active
the first listener works properly. The second, reported to the archivio database, does not work. I perform the test using net manager. The error message is:
the listener is not currently aware of the service requested in connect descriptor
with oracle sql developer i can connect to db archivio if i use local instead of base type connection
Other info:
windows 7 ultimate oracle 12c
LISTNER.ORA
# listener.ora Network Configuration File: C:\Program Files (x86)\Common Files\Quest Shared\instantclient-basic-windows.x64-11.2.0.4.0\listener.ora
# Generated by Oracle configuration tools.
LISTENER1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = webgate1-PC)(PORT = 1522))
)
ADR_BASE_LISTENER1 = C:\app\cirom
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = webgate1-PC)(PORT = 1521))
)
ADR_BASE_LISTENER = C:\app\cirom
ADR_BASE_LISTENER1 = C:\app\cirom
TNSNAMES.ORA
# tnsnames.ora Network Configuration File: C:\Program Files (x86)\Common Files\Quest Shared\instantclient-basic-windows.x64-11.2.0.4.0\tnsnames.ora
# Generated by Oracle configuration tools.
ARCHIVIO =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = webgate1-pc)(PORT = 1522))
)
(CONNECT_DATA =
(SERVICE_NAME = archivio)
)
)
LISTENER_TEST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
LISTENER_ARCHIVIO =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1522))
TEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = webgate1-pc)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = test)
)
)
In order to get an Oracle instance registered on a listener running on not default port (not TCP 1521) you have to configure the LOCAL_LISTENER parameter, for example:
(ADDRESS = (PROTOCOL=TCP)(HOST=hostname)(PORT=1522))
The command is:
alter system set local_listener='(ADDRESS = (PROTOCOL=TCP)(HOST=hostname)(PORT=1522))' scope=both;
Change hostname with you hostname.
Then restart you database or issue the command:
alter system register;
Giovanni

How to acess locally installed Oracle 11 g throught PL/SQL Developer 9

I need to develop in PL SQL using PL/SQL developer but I don't have idea how to make both oracle 11g and pl/sql developer work in the same machine because pl/sql developer need 32 bit oracle client installed when oracle did not require client when we work in local machine.
This is what I did:
1) I installed oracle 11g 64 bit Enterprise on drive d:\
2) Then I installed oracle client 32 bit on drive c:(pl/sql developer can work only with 32 bit version of oci.dll)
3) After I went to the client_home%->Network->Admin folder and corrected tnsname.ora file and wrote there my connection setting which was copied from my oracle 11 g home_dir..tnsnames.ora
MyOracle =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
After I installed PL/SQL developer in c:\plsqldev\ and rebooted my machine.
So now I can connect to my database with sql*plus located in my oracle database directory , but when I try to connect to my oracle with my client sql*plus it says tns protocol error when I try to connect using pl/sql developer it says could not resolve the connection identifier specified. What should I do? Could you help me please
Added:
I erased TNSNAMES parameter from NAMES.DIRECTORY_PATH (in both - server and client sqlnet.ora files) and now when i login it says: ora-12154 tns could not resolve the connect identifier specified , but it still sucessfully connecting to DB when i try to connect with SERVER - s sql*plus.
Here is my config files:
**servers listener.ora **
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = D:\app\Light\product\11.2.0\dbhome_1)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:D:\app\Light\product\11.2.0\dbhome_1\bin\oraclr11.dll")
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
ADR_BASE_LISTENER = D:\app\Light
servers sqlnet.ora
SQLNET.AUTHENTICATION_SERVICES= (NONE)
NAMES.DIRECTORY_PATH= (HOSTNAME)
servers tnsname.ora
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
Clients sqlnet.ora
SQLNET.AUTHENTICATION_SERVICES= (NONE)
NAMES.DIRECTORY_PATH= (HOSTNAME)
Clients tnsnames.ora
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
ADD:
Yess!)) Finally i found the solution: :)
We need to use server's config file instead of clients one - but the oci.dll(32bit) must be taken from clients directory. I will describe the basic steps - how i made pl/sql developer 10.0.2 work with locally installed Oracle 11.2 x64:
1) Fist we need to install Oracle (I installed it to d:\app)
2)Then wee need to download and install oracle instant client (i founded that there are not any config files (not even network->admin directory) in the instant client , just needed dll's like oci.dll and etc.. note: the first time i've choosen "administrator" one which have it's own config file inside, seems this kind of client is needed only for remote access to Oracle). I installed(unpacked) my instant client to c:\app\ ;
3) Open PL/SQL developer , go to tools->preferences->connection and set the "Oracle Home" filed to the home directory of your instant client (I puted c:\app), but usually it already exist in the drop down list and we just need to click the drop down list and choose OraClient11g_home1_32bit , by this way i set the oci library path(choosen from drop down list). Click apply and exit from pl/sql developer;
4) Now we need to create two environment variables(the fist one will show the path to folder with connection configs , the second the language(if i'm not right please correct me)) ->
TNS_ADMIN = %SERVER_HOME%\NETWORK\ADMIN\ (i puted D:\app\Light\product\11.2.0\dbhome_1\NETWORK\ADMIN)
TNS_LANG = AMERICAN_CIS.CL8MSWIN1251
5) Reboot (optionally) and then start pl/sql developer - there must be three connection alias , i choosed orcl , entered my login ,password and hiited OK and everything worked )));
Thank's to everyone who answered in this topic, hope it'll help someone
check the port name in tns file it sholud be 1521 and where XE is my local db name
like this E =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = Shantu)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)

Resources