[英]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.