在jbuilder9+WebLogic8.1+Oracle9i怎么配置及使用WebLogic8.1的连接池?(急!)(200分)

  • 主题发起人 主题发起人 Walnut_Tom
  • 开始时间 开始时间
W

Walnut_Tom

Unregistered / Unconfirmed
GUEST, unregistred user!
在jbuilder9+WebLogic8.1+Oracle9i怎么配置及使用WebLogic8.1的连接池?
麻烦详细说明,谢谢!
 
怎么?没有高手进来?~555555
分不够再加!
 
写起来太累了,网上很多step by step的文章的,这样吧,你碰到什么问题问我吧。
 
在weblogic的控制台的jdbc里
先建一个Connection Pools
然后在建一个Data Sources或Data Sources 就可以
起一个JNDI Name的名字 这以后在你的程序里要用
 
7syw,sunway
你们好,7syw 说的我都设置好了,但在测试时(Testing)有这样的警告信息。
Warning! Connectivity to backend database not verified. This is either because required connection pool attributes "TestConnectionsOnReserve" or "TestConnectionsOnRelease" have not been enabled, or an invalid value has been specified for attribute "TestTableName". Please check the server log for more details..
使用Configuration Wizard测试成功。
Testing Connnection...
Driver=oracle.jdbc.driver.OracleDriver
URL=jdbc:oracle:thin:@192.168.0.34:1521:Ora9i
User=test
Password=***********
SQL Test=SELECT 1 FROM DUAL
Result=1
Test Successful!
当调用时出错。
 
那调用的时候的代码是什么样的呀??
用的时候是用你的起的JNDI Name
 
"Test_DataSourceMap" 是我配置的JNDI:
public static void main(String arg[]) {
Connection con = null;
Statement stmt = null;
try {
Context ctx = new InitialContext();
DataSource ds = (DataSource) ctx.lookup("Test_DataSourceMap");
con = ds.getConnection("test", "test");
stmt = con.createStatement();
stmt.execute("select * from test");
}
catch (java.lang.Exception e) {
e.printStackTrace();
System.err.print(e.getClass().getName());
System.err.println(e.getMessage());
}
}
错误信息
javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:640)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.java:280)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at com.chenwa.pooledConnection.pooledConn.main(pooledConn.java:25)
javax.naming.NoInitialContextExceptionNeed to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
 
public static void main(String arg[]) {
Connection conn=null;
java.sql.Statement stmt=null;
try{
javax.naming.InitialContext initial = new InitialContext();
conn=((javax.sql.DataSource)initial.lookup(jndi的名称)).getConnection();
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE ,ResultSet.CONCUR_READ_ONLY);
stmt.execute("select * from test");
}
catch(Exception e) {
System.out.println("init wrong"+e.getMessage());
}
}
 
init wrong:Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
 
我已经结解决了。
 
不好意思,前几天出差,没上网
 
后退
顶部