`
huangxx
  • 浏览: 321754 次
  • 来自: ...
社区版块
存档分类
最新评论

oracle java.sql.SQLException: 用户身份证明与现有身份证明不匹配

阅读更多

Setting up Oracle JNDI Datasource on Tomcat by Leon van Tegelen

 

In one of the projects I’m involved in we have to make use of specific Oracle JDBC features. The application runs on Tomcat 5.0.27 and connects to the database using a JNDI datasource setup to use connection pooling . When setting this up based on info I found in Steve Muench ’sBC4J Toy Story example I ran into some problems . For some reason I got the following error: “java.sql.SQLException: User credentials doesn’t match the existing ones”. It really drove me nuts. Checking parameternames over and over, checking username and password … But together with Martijn Hinten of Cumquat I managed to track down the problem. This error only occurs if you specify the minLimit parameter, used to specify the minimum number of pooled connections the pool should have. If you ommit it everythings fine .. This is the minimum context file we needed to get the OracleConnectionCacheImpl working

xml 代码

 

  1. <!---->xml version='1.0' encoding='utf-8'?>  
  2. <Context displayName="udo" 
  3. docBase="C:/development/appservers/jakarta-tomcat-5.0.27/webapps/myContext" 
  4. path="/myContext" workDir="workCatalinalocalhostmyContext">  
  5.   <Resource name="jdbc/myDataSource" type="oracle.jdbc.pool.OracleConnectionCacheImpl"/>  
  6.   <ResourceParams name="jdbc/myDataSource">  
  7.     <parameter>  
  8.       <name>factoryname>  
  9.       <value>oracle.jdbc.pool.OracleDataSourceFactoryvalue>  
  10.     parameter>  
  11.     <parameter>  
  12.       <name>passwordname>  
  13.       <value>****value>  
  14.     parameter>  
  15.     <parameter>  
  16.       <name>urlname>  
  17.       <value>jdbc:oracle:thin:@localhost:1521:***value>  
  18.     parameter>  
  19.     <parameter>  
  20.       <name>driverClassNamename>  
  21.       <value>oracle.jdbc.driver.OracleDrivervalue>  
  22.     parameter>  
  23.     <parameter>  
  24.       <name>username>  
  25.       <value>local_uservalue>  
  26.     parameter>  
  27.   ResourceParams>  
  28. Context>  

 

Place this file under the name myContext.xml in tomcat_home/conf/Catalina/localhost. Now you should be able to use this Datasource from within the “myContext” web -application using the following code InitialContext context = new InitialContext(); envContext = (Context) context.lookup("java:comp/env"); ds = (DataSource) envContext.lookup("jdbc/myDataSource");

This entry was posted on Friday, November 19th, 2004 at 3:14 pm and is filed under General, J2EE/Java, Java, Databases, Oracle, Web, AMIS, KC Web/Java. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

<!---->

5 Responses to “Setting up Oracle JNDI Datasource on Tomcat”

  1. Lucas Says:
    see reference from Lecture on JNDI
    An actual example of how someone set this up. In the spirit of the last few weeks here is a blog post from someone who set up a database connection: Setting up Oracle JNDI Datasource on Tomcat. Notice especially “It really drove me nuts”. Check with your psychiatrist before continuing in the field.
  2. Leon van Tegelen Says:
    Well… The really driving me nuts thingy had nothing to do with JNDI as such, but with the configuration of the Oracle DataSource supplying a minLimit parameter. Which in my opinion is a bug in the driver ….
  3. Ajay Says:
    Hi context resource tags: factory oracle.jdbc.pool.OracleDataSourceFactory password tiger driverClassName oracle.jdbc.driver.OracleDriver url jdbc:oracle:thin:@localhost:1521:DEVDB username scott I am using jsp (with JSTL page) as below: < %@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %> < %@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> select name,hphone,caddress from addr

    Results

    I am still getting : Unable to get connection, DataSource invalid: “java.sql.SQLException: User credentials doesn’t match the existing ones” Can you suggest me any solution. Regards Ajay
  4. Gordon Says:
    I just ran into this too, at the end of a long voyage of painful JNDI discovery. I was trying to use the Oracle RowSet implementation, and I hit this, even after I eliminated the minLimit. My take on what happens is that when you specify minLimit, the pool is initialised with the username and password that you specified, or didn’t specified in the resource description. The specific problem I had was because with a RowSet, you specify the datasource name, and you *can* specify the username and password, but that should be optional. In Oracle’s implementation though, the username and password default to “” instead of null; which of course didn’t match the original username and password. I fixed this once by specifying the credentials when I created the RowSet, but then I realised what was happening and set the username and password to null in the RowSet and everything started working:-) Hope this helps Gordon
  5. Luis Junes Says:
    Hello, I have this question … If I only use the libraries concerning to the connection pooling from Oracle… do I have to pay for a license??, I know that if I deploy BC4J Apps (or in general ADF apps) into other Web servers like TomCat I have to pay for a license..but if I only use the OracleConnectionCacheImpl” and related clases to implement a pool……should I have to pay for that?? thankss
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics