lucky_start_izumi
lucky_start_izumi

Reputation: 2591

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

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?

Upvotes: 10

Views: 143966

Answers (9)

Imed Bargaoui
Imed Bargaoui

Reputation: 39

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.

Upvotes: -1

Nikita Poberezkin
Nikita Poberezkin

Reputation: 71

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

Upvotes: 0

MANJUSHA GUNTUR
MANJUSHA GUNTUR

Reputation: 11

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!

Upvotes: 1

isepun
isepun

Reputation: 81

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!

Upvotes: 8

Dosto Kamil
Dosto Kamil

Reputation: 61

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.

Upvotes: 2

RBennitt
RBennitt

Reputation: 91

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).

Upvotes: 9

lucky_start_izumi
lucky_start_izumi

Reputation: 2591

Solved. The problem is I shouldn't use

 factory="oracle.jdbc.pool.OracleDataSourceFactory"

After remove that, it works good!

Upvotes: 2

wweicker
wweicker

Reputation: 4963

  • 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(?)

Upvotes: 1

MaVRoSCy
MaVRoSCy

Reputation: 17839

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

Upvotes: 0

Related Questions