简体   繁体   English

无法在 Eclipse 中建立到 Oracle DBMS 的 JDBC 连接

[英]Unable to establish JDBC connection to Oracle DBMS in Eclipse

I'm using Oracle 18c Express edition and trying to connect to the same using the below code.我正在使用 Oracle 18c Express 版本并尝试使用以下代码连接到相同版本。

DriverManager.getConnection("jdbc:oracle:thin://@localhost:1521/XE", "system", "Root123");

And upon execution, there's an exception:在执行时,有一个例外:

java.sql.SQLException: Invalid Oracle URL specified

I am unable to figure out what's wrong with the URL.我无法弄清楚 URL 出了什么问题。 Kindly help resolve this issue.请帮助解决此问题。 TIA. TIA。

According to Oracle's documentation the URL should be:根据Oracle 的文档,URL 应该是:

jdbc:oracle:<drivertype>:<user>/<password>@<database>

Where user and password can be provided as connection properties:其中用户和密码可以作为连接属性提供:

Connection conn = DriverManager.getConnection
  ("jdbc:oracle:thin:@myhost:1521:orcl", "scott", "tiger");

You probably need to remove the // from the URL as well:您可能还需要从 URL 中删除//

jdbc:oracle:thin:@localhost:1521:XE

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM