java中JDBCf访问数据库时报java.sql.SQLException: ORA-01017: invalid username/password; logon denied的错误

    今天在学习JDBC时,使用Java访问数据时报了如下的错误:

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


at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.O3log.receive2nd(O3log.java:510)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:279)
at oracle.jdbc.driver.OracleConnection.(OracleConnection.java:371)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:551)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:351)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:247)
at com.nantian.oracle.util.OracleUtil.getConnection(OracleUtil.java:35)
at com.nantian.test.UtilTest.myOracleUtilTest(UtilTest.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)


然后我用工具去登陆数据库发现用户登陆不上了,查了一下说是用户的密码已经过期了,所以上网查找相关解决办法处理了一下:

1.首先查询一下用户的profile的类型:

select username ,profile from dba_users;

2.查看制定概要文件(默认为DEFAULT)的密码有效期:

select  * from dba_profiles where profile='DEFAULT' and resource_name='PASSWORD_LIFE_TIME';

3.然后将密码的有效期有180天设置为“无限制”;

ALTER PROFILE  DEFAULT  LIMIT PASSWORD_LIFE_TIME UNLIMITED;

4.修改之后不用重启服务,会立即生效,修改之后没有被提示ORA-28002警告的帐户不会再碰到同样的提示;

  如果已经被提示过了,就必须要修改一次账户的密码:

  sqlplus   /as sysdba;

然后执行 alter user  用户名 identified by 原来的密码---不用换新的密码


你可能感兴趣的:(Oracle,JDBC,oracle,数据库,java,jdbc)