Im gonna do a datasource Tomcat 9.0.63 to connect to my Oracle DB.
Actually we use dataguard (2 db, a main one and a backup one)
In the configuration of server.xml file , in order to set the connection, i wonder in the parameter "URL" if i can use the following syntax:
jdbc:oracle:thin:#(DESCRIPTION = (ADDRESS_LIST =(LOAD_BALANCE=off)(FAILOVER=ON) (ADDRESS = (PROTOCOL = TCP)(HOST = HOSTNAMEMAINDB)(PORT = 1521))(ADDRESS = (PROTOCOL = TCP)(HOST = HOSTNAMEBACKUPDB)(PORT = 1521)))(CONNECT_DATA = (SERVICE_NAME = SERVICENAME) (FAILOVER_MODE = (TYPE = SELECT)(METHOD = BASIC)(RETRIES = 120)(DELAY = 5))))
The questio would be if the datasource tomcat would support this syntax
Thank you very much
Ive tried with non Dataguard configuration and that work, i wonder if that would work with this configuration
Yes, it should be a string that is correctly formed. The long form connection string will work.
Another way is to move the entire connection string to a file named tnsnames.ora with a Name-value pair and then use a TNS Alias in the connection URL and TNS_ADMIN pointing to the location of the tnsnames.ora file (jdbc:oracle:thin:#orcldbtest_medium?TNS_ADMIN=/Users/test/). Refer to JDBC developer guide for more details.
Related
when I log on some oracle database, I can connect without tnsnames.ora. However, when I try to log on some other database, it reject because of TNS:connection timeout. What is changed? What does TNS file do? Why I have to have this ora file?
Thank you
File tnsnames.ora just resolves your database alias to full databases address.
Assume you have an entry as this:
ORA11 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.0)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORA12)
)
)
Then you can start for example SQL*Plus
sqlplus SCOTT#ORA11
or
sqlplus SCOTT#"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.0)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ORA12)))"
It does the same, the first way is just more convenient.
I have implemented the datagaurd in Oracle database for high
availability with two servers and configured the jdbc settings to
connect Jboss application server to always connect primary database
instance.
If I use the following string:
<connection-url>
jdbc:oracle:thin:#(DESCRIPTION=(CONNECT_TIMEOUT=5)(TRANSPORT_CONNECT_TIMEOUT=3)(RETRY_COUNT=3)(ADDRESS_LIST=(LOAD_BALANCE=OFF)(FAILOVER=ON)(ADDRESS=(PROTOCOL=TCP)(HOST=<ip1>)(PORT=<port>))(ADDRESS=(PROTOCOL=TCP)(HOST=<ip2>)(PORT=<port>)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME
= MYDB)(FAILOVER_MODE=(TYPE=SELECT)(METHOD=BASIC))))</connection-url>
When i perform a switch-over/filover the ip1 is down and ip2 is up. If I specify ip2 first in my list then I get a connection (just like I'd expect if I just tried to connect to ip2). However when I put ip1 first I get the same error as if I tried to connect directly to
java.util.concurrent.ExecutionException: java.lang.RuntimeException:
java.sql.SQLException: ORA-01033: ORACLE initialization or shutdown
in progress
Recommended connection URL for a Data Guard with RAC is as shown below. Can you make sure that you are using the correct connection URL ?
jdbc:oracle:thin:#(DESCRIPTION = (FAILOVER=on)
(CONNECT_TIMEOUT= 15) (RETRY_COUNT=20) (RETRY_DELAY=3)
(ADDRESS_LIST =
(LOAD_BALANCE=on)
(ADDRESS = (PROTOCOL = TCP) (HOST=primary-scan) (PORT=1521)))
(ADDRESS_LIST =
(LOAD_BALANCE=on)
(ADDRESS = (PROTOCOL = TCP) (HOST=secondary-scan) (PORT=1521)))
(CONNECT_DATA= (SERVICE_NAME = gold-cloud-service-name)))
I'm new here so I introduce myself, my name is Ettore Giallaurito and my job is in the IT services in Italy.
My question:
I'm trying to connect to an Oracle DB instance through an odbc (System DNS) connections under XP but I get an error ORA1254 TNS:could not resolvethe connect identifier specified.
I'm using oracle instant client 11.2 and I've my tnsnames properly configured, since I can get connected with DBVisualizer using the TNS method.
To be honest I do get connected in this case, but I need to insert the full connect string:
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = repsit01.sit.sor)(PORT = 1521))
(CONNECT_DATA = (SERVICE_NAME = REPSIT01))
)
since it doesn't get me in if I use just the SID, in my case REPSIT01 as showed below.
My tns entry is as follow:
REPSIT01 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.1)(PORT = 1521))
(CONNECT_DATA = (SERVICE_NAME = REPSIT01))
)
Any help would be much apprecciated.
Thanks in advance Ettore.
Try setting the environment variable TNS_ADMIN to the directory where your tnsnames.ora file resides.
I'm trying to connect my local Oracle 11g database using server explorer in Visual Studio 2010. I tried to setup everything as per instruction, but I'm still getting an ORA-12504 error.
Here is the error:
Here is my tnsnames.ora contents:
# tnsnames.ora Network Configuration File: C:\app\rsahi\product\11.2.0\dbhome_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
VENUS =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = SPRPRG020)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = VENUS)
)
)
LISTENER_VENUS =
(ADDRESS = (PROTOCOL = TCP)(HOST = SPRPRG020)(PORT = 1521))
listener.ora file contents,
# listener.ora Network Configuration File: C:\app\rsahi\product\11.2.0\dbhome_1\network\admin\listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = SPRPRG020)(PORT = 1521))
)
)
ADR_BASE_LISTENER = C:\app\rsahi
Try this, in Visual Studio's Server Explorer Data Connection panel:
Data source name: SPRPRG020/VENUS
i.e. the Data source name format is SERVER_NAME_OR_IP/DATABASE_NAME
In the "Connection Properties" -> "Advanced" set in the "Data Source" field the information in format HOST/SERVICE_NAME. E.g. 127.0.0.1/TEST
Without having much knowledge in connecting ODP.NET with an Oracle DB, I suggest you start using SERVICE_NAME (e.g: VENUS) in your connection parameters.
Oracle states that:
From 11g onwards, the feature of using the hostname provided in the /etc/hosts file, as the alias / service name has been changed. As a result, the user will have to provide the service name while connecting OR configure the target listener with a default service name.
One way to bypass the SERVICE_NAME client side requirement is to force the Listener always sending you on the same SERVICE by telling it to do so in the tnsnames.ora
DEFAULT_SERVICE_LISTENER = VENUS
But I do not suggest you do that as it's quite restricting.
I have experienced the same problem when I was trying to create LinkedServer with Oracle 11g. My oracle instance name was: PC-2.my.xgen and my listener name was "NB". The last parameter of first statement is actually the concatenation of Oracle server instance and listener name.
So I have write down the following statements in SQL server.
--add a linked server into SQL server
--last parameter contains OracleInstance / Listener Name of desired database
EXEC sp_addlinkedserver 'OracleLinkedServer4', 'Oracle', 'MSDAORA', 'PC-2.my.xgen/nb'
--add login information into linked server
EXEC sp_addlinkedsrvlogin 'OracleLinkedServer4', false, Null, 'system', '123456'
In Oracle database "NB" I have a table named : CRD_CIL_NOTIFICATION_TYPE. So I have written down the following statement to get the records.
select * from OracleLinkedServer4..SYSTEM.CRD_CIL_NOTIFICATION_TYPE
In the "Connection Properties" -> "Advanced" set in the "Data Source" field the information in format HOST:PORT/SERVICE_NAME. E.g. 10.xxx.xxx.xxx:1521/SIDNAME
I'm trying to connect to a load-balanced virtual host specified in tnsnames.ora in my Grails application in DataSource.groovy, with no luck - it (obviously) throws an "Unknown Host Specified" exception.
The tnsnames entry looks like this
someServiceName =
(DESCRIPTION_LIST =
(FAILOVER=ON)
(LOAD_BALANCE=ON)
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = someServerName1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = someServiceName1)
)
)
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = someServerName2)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = someServiceName2)
)
)
)
I can connect to one of the services (someServiceName1 & someServiceName2) by simply setting the values in DataSource.groovy in the usual way, but I don't know how to connect to the load-balanced virtual host.
I've searched around for using tnsnames.ora in Grails but I can't seem to find a particularly "groovy" way of making this work. Any pointers will be appreciated.
P.S. I would prefer a solution where I would still be able to inject the dataSource into my controllers etc.
I think you need to configure a single service with multiple addresses. Then you have to set your datasource URL string to something like this (without the newlines of course):
jdbc:oracle:thin#(DESCRIPTION=
(LOAD_BALANCE=on)
(ADDRESS=(PROTOCOL=TCP)(HOST=someServerName1) (PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=someServerName2) (PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=theOnlyServiceName)))
Look here and here for references.
You could use
jdbc:oracle:oci:#someServiceName
I use this, notice it's oci, not thin. It works for me.
Just ran into this issue, here's what fixed it for me:
url='jdbc:oracle:thin:#servername:PORT/servicename'
It was the forward slash between the port and the service name that tripped me up. If you use a colon there, it reads it as a SID instead of a service name.
Good luck!