[英]Tomcat 7 and Oracle Connection Pooling
I am attempting to use connection pooling with tomcat 7 and connecting to an Oracle database. 我试图将连接池与tomcat 7一起使用并连接到Oracle数据库。 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, 我正在使用谷歌guice注入数据源,
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; javax.naming.NamingException:ORA-01017:无效的用户名/密码; 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?
我在Guice上做错什么了吗,还是与Oracle(我相信9i)的连接池设置不同?
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. 除了在Resource元素中设置用户名和密码属性外,您还需要在URL中包括用户名和密码。
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" ... />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.