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 代码
- <!---->xml version='1.0' encoding='utf-8'?>
- <Context displayName="udo"
- docBase="C:/development/appservers/jakarta-tomcat-5.0.27/webapps/myContext"
- path="/myContext" workDir="workCatalinalocalhostmyContext">
- <Resource name="jdbc/myDataSource" type="oracle.jdbc.pool.OracleConnectionCacheImpl"/>
- <ResourceParams name="jdbc/myDataSource">
- <parameter>
- <name>factoryname>
- <value>oracle.jdbc.pool.OracleDataSourceFactoryvalue>
- parameter>
- <parameter>
- <name>passwordname>
- <value>****value>
- parameter>
- <parameter>
- <name>urlname>
- <value>jdbc:oracle:thin:@localhost:1521:***value>
- parameter>
- <parameter>
- <name>driverClassNamename>
- <value>oracle.jdbc.driver.OracleDrivervalue>
- parameter>
- <parameter>
- <name>username>
- <value>local_uservalue>
- parameter>
- ResourceParams>
- Context>
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.
<!---->
December 8th, 2004 at 3:56 pm see reference from Lecture on JNDI
December 8th, 2004 at 4:07 pm 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 ….
September 3rd, 2005 at 11:25 am 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
February 2nd, 2006 at 2:49 pm 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
June 6th, 2006 at 1:15 am 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