I am attempting to use connection pooling with tomcat 7 and connecting to an Oracle database. At the minute my context looks like this
<Resource
type="org.apache.tomcat.jdbc.pool.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
url="my-url"
username="username"
password="password"
I am using google guice to inject the DataSource,
bind(Context.class).to(InitialContext.class);
bind(DataSource.class).toProvider(fromJndi(OracleDataSource.class,"java:comp/env/jdbc/nameToUse"));
however it does appear to be creating the provider, but anytime it calls it I always get a RunTime error with
javax.naming.NamingException: ORA-01017: invalid username/password; logon denied
even though the login details are definitely correct - they work if I switch back to the old way of connecting to the database. Am I doing something wrong, with Guice, or is the connection pool with Oracle (9i I believe) setup differently?
Any help is much appreciated
You need to include the username and password in the URL - in addition to setting username and password attributes in the Resource element.
Eg
<Resource
type="org.apache.tomcat.jdbc.pool.DataSource"
driverClassName="oracle.jdbc.OracleDriver"
factory="org.apache.tomcat.jdbc.pool.DataSourceFactory"
url="jdbc:oracle:thin:joebob/jbpass@mydbhost.example.com:1521/db"
username="joebob"
password="jbpass" ... />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.