各位老大,我用weblogic连oracle8.1.7的数据库的连接池.
总是不成功.具体情况如下:
请问这是什么原因啊??????
连接池:
name: mypool
url: jdbc:oracle:thin:@localhost:1521:orcl
driver classname: oracle.jdbc.driver.OracleDriver
properties: user=zhao
password: **************//这个密码是它自动生成的.我oracle的用户密码也是zhao.不知道为什么这个密码是什么意思??
数据源:
name: mysou
jndi name : myname
pool name: mypool
jsp页面是这样的:
<%@ page contentType="text/html;charset=GBK" %>
<%@ page language="java" %>
<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="javax.naming.*" %>
<HTML>
<HEAD>
<TITLE> </TITLE>
<META NAME="Generator" CONTENT="EditPlus2.11">
</HEAD>
<BODY>
<%
Context ctx = null;
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,"t3://127.0.0.1:7001");
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
try {
ctx = new InitialContext(ht);
DataSource ds = (DataSource)ctx.lookup("myname");
conn = ds.getConnection();
stmt = conn.createStatement();
rs = stmt.executeQuery("select * from cat");
while (rs.next()){
out.println( rs.getString("catename")+"-----");
out.println( rs.getString("catesex")+"<br>");
}
rs.close();
stmt.close();
conn.close();
}catch (Exception e){
out.println("错误 !! ERR !"+e );
}
finally {
try {
ctx.close();
} catch (Exception e) {
out.println("ctx ERR !" ); }
try {
if (rs != null) rs.close();
} catch (Exception e) {
out.println("rs ERR !" ); }
try {
if (stmt != null) stmt.close();
} catch (Exception e) {
out.println("stmt ERR !" ); }
try {
if (conn != null) conn.close();
} catch (Exception e) {
out.println("conn ERR !" ); } }
%>
</BODY>
</HTML>
提示的错误是这样的:
java.sql.SQLException: Cannot obtain connection: driverURL = jdbc:weblogic:pool:mypool, props = {enableTwoPhaseCommit=false, jdbcTxDataSource=true, connectionPoolID=mypool, dataSourceName=mysou}.
Nested Exception: java.lang.RuntimeException: Failed to Generate Wrapper Class at weblogic.utils.wrapper.WrapperFactory.createWrapper(WrapperFactory.java:154) at weblogic.jdbc.wrapper.
6 个解决方案
如果JSP就在这个Weblogic服务器上运行,这句
ctx = new InitialContext(ht);
改成这样
ctx = new InitialContext();
另外,如果想测试Pool连接是否成功,可以在console里面,pool上写上测试连接的语句,诸如
select sysdate from dual;
还有就要确认你连接的数据库的SID是orcl这个吗?
我把这句
ctx = new InitialContext(ht);
改成这样
ctx = new InitialContext();
现在出现的错误是:
weblogic.jdbc.extensions.PoolLimitSQLException: weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool mypool to allocate to applications, please increase the size of the pool and retry..
麻烦高人指点一下:
1,为什么要这样改???
2,在pool上写上测试连接的语句写在哪儿??
1.ctx = new InitialContext(ht);改成这样ctx = new InitialContext();不是解决问题的办法。
2.错误信息“weblogic.jdbc.extensions.PoolLimitSQLException: weblogic.common.resourcepool.ResourceLimitException: No resources currently available in pool mypool to allocate to applications, please increase the size of the pool and retry."
要求在weblogic控制台中配置连接池中初始化的连接数,默认值:初始化数=1、最大连接数=1、递增数=1,把这些值改大就可以了。
楼上老大现在错误又变成刚开始的那样了麻烦你帮忙到底是怎么回事啊????
测试时你要把TestConnectionsOnRelease,TestConnectionsOnReserve设为可用,或者在TestTableName键入名称。
我也是用oracle进行的配置。
url: jdbc:oracle:thin:@localhost:1521:TYG
driver classname: oracle.jdbc.driver.OracleDriver
sa=system
配置完以后先测试看看能否连接成功,然后部署到myserver。
我的时可以了。