指定的Oracle URL无效:OracleDataSource.makeURL [英] Invalid Oracle URL specified: OracleDataSource.makeURL

查看:187
本文介绍了指定的Oracle URL无效:OracleDataSource.makeURL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试连接到本地oracle数据库但是我收到了这个神秘的错误消息:
指定的Oracle URL无效:OracleDataSource.makeURL

I'm trying to connect to a local oracle database but I'm getting this cryptic error message: Invalid Oracle URL specified: OracleDataSource.makeURL.

我很确定这是由于我传递的数据库连接参数出错,但实际上,此错误消息对我没有任何帮助。任何关于我做错的提示都将不胜感激。

I'm pretty sure this is due to an error with the database connection parameters I'm passing, but really, this error message does not help me in any way. Any hints as to what I'm doing wrong would be greatly appreciated.

FYI:用于连接的代码如下,除了硬编码字符串这是用于我们的生产环境并在那里工作。

FYI: Code used to connect is below, except for the hardcoded strings this is what is used on our production environment and does work there.

OracleDataSource dataSource = new OracleDataSource();
 dataSource.setServerName("localhost");
 dataSource.setUser(userName);
 dataSource.setPassword(password);
 dataSource.setDatabaseName("orcl");
return dataSource.getConnection();


推荐答案

令人惊讶的是,在将以下两行添加到代码中之后它创建了连接,它工作。

Surprisingly, after adding the following two lines to the code which created the connection, it worked.

dataSource.setPortNumber(1521);
dataSource.setDriverType("thin");

我不明白为什么我们以前没有这个问题,但这可能有事情要做与我的本地安装。我最大的好处是错误消息没有提供有关错误的任何细节。

I don't understand why we did not have that problem before, but that may have something to do with my local install. My biggest beef is with the error message not giving any detail about what is wrong though.

这篇关于指定的Oracle URL无效:OracleDataSource.makeURL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆