Invalid connection string format, a valid format is: "host:port:sid"

56 Views Asked by At

I have the error: "Could not get JDBC Connection; nested exception is org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Exception IO: Invalid connection string format, a valid format is: "host:port:sid" )"

with the following applicationContext.xml:

`

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"  singleton="true">
    <property name="driverClassName">
        <value>oracle.jdbc.driver.OracleDriver</value>
    </property>
    <property name="url">
       
        <value>jdbc:oracle:thin:@myhost:myport/myservicename</value>

    </property>
    <property name="username">
        <value>username</value>
    </property>
    <property name="password">
        <value>password</value>
    </property>
</bean>



<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource">
        <ref local="dataSource"/>
    </property>
</bean>

<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
    <property name="dataSource">
        <ref bean="dataSource"/>
    </property>
</bean>

.... `

I'm using a service name instead of a sid, but as you can see from the exception, it is being recognized as a sid.

I want to understand how to make it understand that it's a service name and not a sid.

1

There are 1 best solutions below

0
Nirmala On

Print the connection URL and check if there are any extra characters such as / is getting added. Also, try to use the same URL and connect using SQLPLus.