The question is published on by Tutorial Guruji team.
I know this questions has been asked before but the answers does not addressing the problem in my case.
The answer selected by the user talks about the different approach, With the help of the suggested approach my application is working fine but I am want to do it in below manner.
Wanted to put my JNDI xml file containing db connection details in
and when I am running the tomcat from command prompt It should make a connection with the database. In this case my xml file name is application.xml. Running application from command prompt giving me error as
Cannot create JDBC driver of class '' for connect URL 'null' Oracle
Steps I have tried:
- below is the XML file created JNDI resource:
<?xml version="1.0" encoding="UTF-8"?> <Context path="/application" reloadable="false"> <Logger className="org.apache.catalina.logger.FileLogger" prefix="application." suffix=".log" timestamp="true"/> <Resource name="jdbc/application" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory" auth="Container" type="javax.sql.DataSource" username="abc" password="abc" driverClassName="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@<<server_address>:1522:<<sid>>" maxActive="20" maxWait ="10000" maxIdle="10"/> </Context>
` with the information
- web.xml have a entry for the above resource as
`<resource-ref> <description>Connection Pool</description> <res-ref-name>jdbc/application</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Container</res-auth> </resource-ref>
- Put ojdbc6.jar file in tomcat/lib folder.
I am making sure that I have not put ojdbc6.jar in both tomcat and my project and I am using oracle 12c as a database.
The issue was with the filename. My application WAR name was “TomcatExample.war” and xml name was “tomcatexample.xml” It is case sensitive in tomcat 7 and that is the reason it was not picking up the file. Changes to “TomcatExample.xml” works for me. Thank you so much all for your help. Cheers!!!