简体   繁体   English

使用Spring jdbc模板的Oracle连接ORA-12514

[英]Oracle connection using Spring jdbc template, ORA-12514

I am very new to Spring JDBC template. 我是Spring JDBC模板的新手。 I am trying to run a sort of hello world program. 我正在尝试运行某种Hello World程序。

My issues is if I define url as : 我的问题是,如果我将url定义为:

jdbc:oracle:thin:@some_host:1521:some_service

it works perfectly fine, however defining like below throws the above mentioned error. 它工作得很好,但是像下面这样定义会引发上述错误。

jdbc:oracle:thin:@(DESCRIPTION= 
   (ADDRESS=(PROTOCOL=TCP)(HOST=some_host) (PORT=1521)) 
   (CONNECT_DATA=(SERVICE_NAME=some_service)))

Here is my beans.xml , What am I doing wrong? 这是我的beans.xml ,我做错了什么?

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.xsd ">

    <bean id="dataSource" class="oracle.ucp.jdbc.PoolDataSourceFactory" factory-method="getPoolDataSource">
        <property name="URL" value="jdbc:oracle:thin:@(DESCRIPTION= 
            (ADDRESS=(PROTOCOL=TCP)(HOST=some_host) (PORT=1521)) 
            (CONNECT_DATA=(SERVICE_NAME=some_service)))" />
    <!--  property name="URL" value="jdbc:oracle:thin:@some_host:1521:some_service" /> -->
        <property name="User" value="some_user" />
        <property name="Password" value="some_password" />
        <property name="ConnectionFactoryClassName" value="oracle.jdbc.replay.OracleDataSourceImpl" />
        <property name="ConnectionPoolName" value="mypool" />
        <property name="MinPoolSize" value="1" />
        <property name="MaxPoolSize" value="20" />
        <property name="InitialPoolSize" value="1" />
    </bean>

    <!-- Definition for studentJDBCTemplate bean -->
    <bean id="studentJDBCTemplate" class="StudentJDBCTemplate">
        <property name="dataSource" ref="dataSource" />
    </bean>

</beans>

In the connection string :some_service means the SID(the service name is placed after / ). 在连接字符串中:some_service表示SID(服务名称位于/之后)。 So if the jdbc:oracle:thin:@some_host:1521:some_service is correct then some_service is the SID name, the service name is probably something else. 因此,如果jdbc:oracle:thin:@some_host:1521:some_service是正确的,那么some_service是SID名称,则服务名称可能是其他名称。

See here http://www.orafaq.com/wiki/JDBC 看到这里http://www.orafaq.com/wiki/JDBC

You can use something like 您可以使用类似

ORCL =
 (DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = myhost)(PORT = 1521))
   (CONNECT_DATA =
     (SID = ORCL)
   )
 )

It is not legal to use a CR and/or LF in a XML attribute value. 在XML属性值中使用CR和/或LF是不合法的。

So remove that from 所以从

<property name="URL" value="...no CR/LF here ..."

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 监听器拒绝连接以下错误:ORA-12514 - Listener refused the connection with the following error: ORA-12514 使用 Java 连接到 Amazon RDS 实例时如何解决 ORA-12514 - How can I resolve an ORA-12514 when connecting to an Amazon RDS instance using Java 使用Spring JDBC Template的连接异常 - Connection exception using Spring JDBC Template ORA-12514:TNS:侦听器当前不知道连接描述符中请求的服务 - ORA-12514: TNS:listener does not currently know of service requested in connect descriptor Java代码出现ORA-12514错误,但我可以通过外部程序进行连接 - Java code gives ORA-12514 error, yet I can connect via external program 使用 oracle jdbc 模板在 java 中创建新的数据库连接 - Creation of new database connection in java using oracle jdbc template 在JBoss DB Source Configuration中获取“ ORA-12514,TNS:listener当前不知道连接描述符中请求的服务” - Getting “ORA-12514, TNS:listener does not currently know of service requested in connect descriptor” in JBoss DB Source Configuration 将Spring JDBC用于Oracle存储过程,当SP抛出ORA-20118时,我得到ORA-02055 - Using Spring JDBC for Oracle Stored Procedure I get a ORA-02055 when SP throws ORA-20118 没有监听器的 JDBC 远程 Oracle 连接 (TNSNAMES.ora) - JDBC remote Oracle connection without listener (TNSNAMES.ora) JDBC Oracle Thin ORA-02396 连接空闲超时 - JDBC Oracle Thin ORA-02396 Connection idle timeout
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM