java – 无法使用Spring Boot和Hibernate连接到Oracle
我有一个使用Postgres的
Spring Boot应用程序(1.2).今天我正在尝试将其切换到Oracle,但是当我尝试连接时,我得到一个异常,说:
java.sql.SQLRecoverableException: IO Error: The Network Adapter could not establish the connection 在那之下, Caused by: java.net.ConnectException: Connection refused 当然,这看起来像是糟糕的凭据,但我知道它们很好,而且他们在Oracle SQL Developer中工作得很好.我很困惑.这是我的属性文件条目: # Properties for Hibernate and Oracle spring.datasource.driverClassName=oracle.jdbc.driver.OracleDriver spring.datasource.url=jdbc:oracle:thin:@//earth-db-11:5121/stardev spring.datasource.username=ops$abcdefg spring.datasource.password=mypassword spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect 我唯一的想法就是用户名中有一个$,我试图转义并在其周围加上双引号. 有任何想法吗? 谢谢… 更新: 非常感谢BonanzaOne,我的端口号错了.更正会导致新错误: java.sql.SQLRecoverableException: Listener refused the connection with the following error: ORA-12514,TNS:listener does not currently know of service requested in connect descriptor 当然,我查了一下,但我没有按照它告诉我的说法: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor Cause: The listener received a request to establish a connection to a database or other service. The connect descriptor received by the listener specified a service name for a service (usually a database service) that either has not yet dynamically registered with the listener or has not been statically configured for the listener. This may be a temporary condition such as after the listener has started,but before the database instance has registered with the listener. 不过,SQL Explorer连接正常. 解决方法
该异常意味着Oracle侦听器未启动,或者您尝试连接到不存在/不可访问的侦听器.
我的猜测是你尝试错误的端口“5121”. Oracle默认端口是1521. 你可以尝试一下,看看会发生什么? 从FAQ开始,基本上有两种组成JDBC字符串URL的方法:
我的猜测是你使用了错误的语法-SID /服务名称组合,换句话说,你使用的是需要SERVICE名称的新语法,但是你使用SID名称来执行它. 试试这个:jdbc:oracle:thin:@ earth-db-11:1521:stardev 或者找出服务名称并将其应用于您正在使用的新语法,而不是SID名称. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |