当用jdbc连接Oracle数据库的时候

   private Connection getConnection() throws SQLException
{
OracleDataSource ods = new OracleDataSource();
ods.setUser("biaoJM");
ods.setPassword("123456");
ods.setURL("jdbc:oracle:thin:@localhost:1521:orcl");
return ods.getConnection();
}

出现:

java.sql.SQLException:ORA-01017: invalid username/password; logon denied

但是我在sqlplus中可以登录

可能的原因如下:

Checklistfor ORA-01017 errors:
select username from dba_users;

The core issue with anORA-01017 error is an invalid user ID and passwords combination, but other thanan incorrect password, there are user ID issues that may contribute to theORA-01017 error:

  • It may be that the userID is invalid for the target system - The user ID exists as theusername columnin the dba_users view.
  • Check your $ORACLE_SIDenvironmental parameter.  If your $ORACLE_SID is set to the wrong systemID then you may get a ORA-01017 error because you are connecting to the wrongdatabase.
  • If using external OS userauthentication (ops$ or remote_os_authent) you need to verify that the user ID is valid.  You can tellif you are using external authentication because you connect without providinga user/password combination, and only provide a forward slash to the connectstring, (e.g. connect / as sysdba;).  
  • Check your tnsnames.ora to ensurethat the TNS service name points to the correct server and instance name. If you specify an incorrect tnsnames.ora service name, thenthe user ID and password may not exist in that database.

我的原因是第二条

在sqlplus用conn as sysdba登陆

用select name from V$database; 查看当前的SID,发现是FIRSTDB

那么我的URL应该将orcl改为FIRSTDB

之后就可以了

我的Oracle一共有两个数据库,分别为orcl和firstdb,这个可以执行Oracle中的administration assistance for Windows查看:

注:Oracle安装目录下有JDBC的文件夹,里面有一份文档很有参考价值,说明了如何配置以及如何使用

D:\app\Administrator\product\11.2.0\dbhome_1\jdbc

JDBC连接ORACLE无法登陆java.sql.SQLException: ORA-01017: invalid username/password; logon denied的更多相关文章

  1. LR连接oracle时出现:SQLState=28000[Oracle][ODBC][Ora]ORA-01017:invalid username/password;logon denied

    出现的现象:

  2. Oracle使用命令行登录提示ERROR: ORA-01017: invalid username/password; logon denied

    刚在Windows上面安装好Oracle 10g,刚开始使用PLSQLDevelop软件登录提示  not logged on ,然后使用命令行登录提示 ERROR: ORA-01017: inval ...

  3. sqlplus登录Oracle时ORA-01017: invalid username/password; logon denied的错误

    今天用scott用户登录Oracle数 据库时,竟然出现了ORA-01017: invalid username/password; logon denied错误,原以为是因为我的scott用户没有解 ...

  4. Oracle 12C 密码文件问题 ORA-01017: invalid username/password; logon denied

    新安装的Oracle 12.1.0.2.0,NBU在测试备份的时候报ORA-01017 --alter user sys identified by "Wwjd!23";sqlpl ...

  5. oracle 12c ORA-01017:invalid username/password; logon denied

    Oracle 12C 中,想通过操作系统认证登录Oracle 数据库,有一些要注意的地方.不然就会遇到 ORA-01017:invalid username/password; logon denie ...

  6. 登录PL/SQL无法登录,提示错误:ORA-01017: invalid username/password; logon denied 错误

    在使用在登录PL/SQL(使用scott用户)无法登录,提示错误:ORA-01017: invalid username/password; logon denied 错误(程序中的用户和密码无法登录 ...

  7. Oracle SQLDeveloper ORA-01017 invalid username/password;logon denied (密码丢失解决方案)

    oracle sys账号用sql developer工具无法登陆 用户名和密码不一致 如果的确是丢失密码的话:在SQL*Plus中执行如下命令:   SQL>conn/as sysdba (操作 ...

  8. Oracle 数据库基础 出现invalid username/password; logon denied错误解决方案

    出现invalid username/password; logon denied错误解决方案 [win7或win8中 cmd要以管理员身份运行] 1.Dos下输入命令:sqlplus sys/安装时 ...

  9. 2016.11.10 Could not get JDBC Connection; nested exception is java.sql.SQLException: No suitable driver

    运行项目rds_web时,出现错误提示:Could not get JDBC Connection; nested exception is java.sql.SQLException: No sui ...

随机推荐

  1. Windows 10 Mobile 演示:插入耳机自动执行 APP

    Windows Mobile 10 新特性:插入外部设备自动动作(如插入耳机执行 APP.打开小工具):另外可以找到最后一次使用设备地点和时间: http://www.tudou.com/progra ...

  2. HTML 导航框架

    首页效果图 点击链接一效果图 代码结构 index.jsp <%@ page language="java" import="java.util.*" p ...

  3. 字符串格式化输出、while循环、运算符、编码

    1.字符串格式化输出 %占位符: %s => 字符串 %d=>整数型 %%=>转义 普通的% %()不能多,不能少,一一对应 f"{}"大括号里的内容一般都放变量 ...

  4. (2016北京集训十三)【xsy1532】网络战争 - 最小割树+树上倍增+KD树

    题解: 好题!! 这题似乎能上我代码长度记录的前五? 调试时间长度应该也能上前五QAQ 首先题目要求的明显就是最小割,当然在整个森林上求Q次最小割肯定是会GG的,所以我们需要一个能快速求最小割的算法— ...

  5. Jtester使用

    1.在Jtester中使用DataMap 为什么要使用DataMap? 早先的jTester中提供了dbFit方式来准备和验证数据库数据,应该来说,这个工具解决了很多问题.实际使用过程中,开发同学反映 ...

  6. 解决jquery动态增加元素后children值没有变的问题

    html代码如下: <ul id="attr_input_panel"> <li> <div class="attr_input_item& ...

  7. NSURLConnection和NSRunLoop

    主线程中创建一个NSURLConnection并异步运行 [self performSelectorOnMainThread:@selector(start) withObject:nil waitU ...

  8. poj_3371

    一道模拟题,写的有点麻烦 #include<iostream> #include<cstring> #include<cstdio> #include<alg ...

  9. layer是什么

    layer是什么 总结 layer就是一个web弹框 简介 layer是一款web弹层组件,致力于服务各个水平段的开发人员. 可以让你想到即可做到的web弹窗 概述 [1]  layer,一个可以让你 ...

  10. FZOJ--2212--Super Mobile Charger(水题)

    Problem 2212 Super Mobile Charger Accept: 3    Submit: 11 Time Limit: 1000 mSec    Memory Limit : 32 ...