giving correct username& password, get ORA-01017: invalid username/password; logon denied
Asked Answered
P

9

10

I have oracle database configuration in tomcat's server.xml

<Resource name="jdbc/sgfdb" auth="Container"
          driverClassName="oracle.jdbc.OracleDriver"
          url="jdbc:oracle:thin:@databaseurl:1521:schema"
          username="username" password="password" maxActive="20" maxIdle="10"
          maxWait="-1"
          factory="oracle.jdbc.pool.OracleDataSourceFactory"
          type="oracle.jdbc.pool.OracleDataSource"/>

Then in my web app (spring mvc project), i declear this in context.xml

<Context>
 <ResourceLink name="jdbc/sgfdb"
        global="jdbc/sgfdb"
        type="javax.sql.DataSource"/>
</Context>

I was able to connect to this database before. I didn't work on it for a week. Then now when i try to start it, always get:

SEVERE: Servlet.service() for servlet [action] in context with path [/WebUI] threw exception [Request processing failed; nested exception is javax.persistence.QueryTimeoutException: Could not open connection] with root cause
**java.sql.SQLException: ORA-01017: invalid username/password; logon denied**

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:389)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:382)
at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:573)
at    oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:431)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:366)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:752)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:366)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:536)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:228)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at oracle.jdbc.pool.OracleDataSource.getPhysicalConnection(OracleDataSource.java:280)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:207)
at oracle.jdbc.pool.OracleDataSource.getConnection(OracleDataSource.java:157)
at org.hibernate.ejb.connection.InjectedDataSourceConnectionProvider.getConnection(InjectedDataSourceConnectionProvider.java:70)
at org.hibernate.internal.AbstractSessionImpl$NonContextualJdbcConnectionAccess.obtainConnection(AbstractSessionImpl.java:278)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.obtainConnection(LogicalConnectionImpl.java:297)
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.getConnection(LogicalConnectionImpl.java:169)
at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.extractPhysicalConnection(ConnectionProxyHandler.java:82)
at org.hibernate.engine.jdbc.internal.proxy.ConnectionProxyHandler.continueInvocation(ConnectionProxyHandler.java:138)
at org.hibernate.engine.jdbc.internal.proxy.AbstractProxyHandler.invoke(AbstractProxyHandler.java:81)
at $Proxy36.prepareStatement(Unknown Source)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$5.doPrepare(StatementPreparerImpl.java:147)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl$StatementPreparationTemplate.prepareStatement(StatementPreparerImpl.java:166)
at org.hibernate.engine.jdbc.internal.StatementPreparerImpl.prepareQueryStatement(StatementPreparerImpl.java:145)
at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1720)
at org.hibernate.loader.Loader.doQuery(Loader.java:828)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:289)
at org.hibernate.loader.Loader.doList(Loader.java:2447)
at org.hibernate.loader.Loader.doList(Loader.java:2433)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2263)
at org.hibernate.loader.Loader.list(Loader.java:2258)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:195)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1215)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at org.hibernate.ejb.QueryImpl.getSingleResult(QueryImpl.java:284)
at org.hibernate.ejb.criteria.CriteriaQueryCompiler$3.getSingleResult(CriteriaQueryCompiler.java:258)
at mycompany.services.impl.JobServiceImpl.getNumberOfJobs(JobServiceImpl.java:51)
at mycompany.controller.ExecJobController.execJobList(ExecJobController.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.web.method.support.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:213)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:126)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:96)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:617)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:578)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:80)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:923)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:789)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:225)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:169)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:168)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:98)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:927)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:407)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:999)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:565)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:307)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)

I am sure the username and password are correct. Could anyone please give me some hint about what's going on here?

Powe answered 29/6, 2012 at 17:25 Comment(5)
Why do you believe that the password is correct? If the code worked in the past and the code has not been changed, the logical inference is that the password must have changed. Perhaps the password didn't change but the DBA enabled case-sensitive passwords so that the password you have stored became incorrect.Quintie
I am using this database now also. I can use this password to connect from sql developer on the same machine now! Thank youPowe
How is the connection in SQL Developer configured? Are you using a Basic connection? A TNS connection? Something else? When you posted the JDBC URL your application is using, did you inadvertently type schema where you meant service name-- jdbc:oracle:thin:@databaseurl:1521:schema should be jdbc:oracle:thin:@databaseurl:1521:service name. The error you're getting indicates that the username & password are incorrect. Either the password is incorrect, the user name is incorrect, or you're trying to connect to the wrong database.Quintie
possible duplicate of Oracle JDBC : invalid username/password (ora-01017)Underhanded
I have search everywhere, and then found following article(followed the step by step approach , it worked) : codejava.net/java-se/jdbc/connect-to-oracle-database-via-jdbc , I followed : String dbURL = "jdbc:oracle:thin:tiger/scott@localhost:1521:productDB"; Connection conn = DriverManager.getConnection(dbURL); if (conn != null) { System.out.println("Connected"); }Fleck
P
2

Solved. The problem is I shouldn't use

 factory="oracle.jdbc.pool.OracleDataSourceFactory"

After remove that, it works good!

Powe answered 6/7, 2012 at 17:10 Comment(2)
where is this ??, in which file can i find it ?Monosaccharide
I dont have this factory object and still the issue exist.Patsy
F
9

Just solved a problem similar to this. If an 11g database is configured for case sensitive passwords, but you're trying to connect using a 10g client, the 10g client will send the password all in upper case to the database, hence an invalid password when the password you typed in is clearly correct. So you need to upgrade the client to 11g to get it to send the password in the correct case (but for a quick test you can change your password to all upper case and you'll be able to connect).

Fredi answered 19/11, 2012 at 12:26 Comment(1)
11g is now supported. All you have to do is use org.hibernate.dialect.Oracle10gDialectKobe
P
8

Bumped into this thread because I was facing the same problem. The username and password were perfect. Was able to login using those credentials in SQLPlus and from other applications. The datasource.url was also perfect.

While analyzing the errors, found that the ojdbc6.jar that I was using was trying to connect to Oracle 11.1.0.7 whereas my Oracle was 11.2.0.4. Downloaded the latest ojdbc6.jar and tried to connect and voila!

Paisano answered 2/2, 2017 at 7:34 Comment(0)
P
2

Solved. The problem is I shouldn't use

 factory="oracle.jdbc.pool.OracleDataSourceFactory"

After remove that, it works good!

Powe answered 6/7, 2012 at 17:10 Comment(2)
where is this ??, in which file can i find it ?Monosaccharide
I dont have this factory object and still the issue exist.Patsy
Y
2

If your password and username are lowercase and their uppercase mode have different value (like i, İ in Turkish) this might cause the problem. Some Java- Oracle connection libraries make them uppercase without watching the culture differences.

Yandell answered 19/3, 2015 at 15:46 Comment(0)
S
1
  • The username could be incorrect.
  • The password could be incorrect.
  • The server/instance you are connecting to could be incorrect, or different between your machine and the server, or between the application and SQL Developer.
  • The database might be configured to use case sensitive passwords.
  • The password might contain a semicolon ; character causing the connection string to get truncated when the application builds the connection string, but allowing you to use it from SQL Developer(?)
  • You could have a typo somewhere(?)
Stavro answered 29/6, 2012 at 20:16 Comment(1)
I am 180% sure username is correct, password is corrent, Url is correct (I am not giving my url here.) I am able to connect from sql developer with the same url, username,password. I was just wondering because i have db configured in tomcat, is there something in my config goes wrong or anything? But u people just feel i don't give the correct username/password. Come on!!!!!! Those are the basic, how people would take effort to post questions before they do basic check first!Powe
C
1

I have similar issue where password works in SQL Developer but not in code (Java). I tried to reset the password and it works fine. Not sure of the root cause but it works. Hope this helps!

Canto answered 24/10, 2019 at 23:17 Comment(1)
I also had the same issue . Upgraded to 19c from 12g and the same username password not working via JDBC but SQLplus worked fine. So I did a password reset and everything started to work.Horwath
R
0

it is possible that the user you are trying to logon has an expired password

Rochdale answered 29/6, 2012 at 17:29 Comment(0)
M
0

For me incompatible version of OracleDriver was causing this issue Your application should either register oracle driver manually (which jar that I needed to work with was doing) or agter java 6 ojdbc.jar should be in the classpath for your application. So google compatible driver version for your oracle installation and either declare it in your pom file (with needed plugin to put it in the resulting jar) and reference it manually from code or put the ojdbc.jar somewhere your jar can see it Usefull links:

About connecting to oracle db: https://www.codejava.net/java-se/jdbc/connect-to-oracle-database-via-jdbc

About java classpath: https://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html

Muscarine answered 8/10, 2020 at 12:40 Comment(0)
M
-1

You should change the value of FipsAlgorithmPolicy in system register:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy] "Enabled" = dword: 00000000

You don't need to reboot the OS.

Marcelmarcela answered 15/11, 2020 at 15:9 Comment(1)
What exactly does this actually do? why do we need to go into the registry to make this change? won't this affect you other functionalities on the computer?Linguiform

© 2022 - 2024 — McMap. All rights reserved.