不好意思,上面的代码复制错了,呵呵!
Connection conn00 = null;
Statement stmt00 = null;
ResultSet rs00 = null;
try{
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,
"t3://localhost:7001");
Context ctx = new InitialContext(ht);
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("kksource");
conn00 = ds.getConnection();
}
catch(Exception e)
{
out.println("硈钡戈畐ア毖!!");
}
stmt00 = conn00.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
Connection conn00 = null;
Statement stmt00 = null;
ResultSet rs00 = null;
try{
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,
"t3://localhost:7001");
Context ctx = new InitialContext(ht);
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("kksource");
conn00 = ds.getConnection();
}
catch(Exception e)
{
out.println("硈钡戈畐ア毖!!");
}
stmt00 = conn00.createStatement(java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,java.sql.ResultSet.CONCUR_READ_ONLY);
stmt00 = conn00.createStatement();试试
JNDI Name: kksource
自动生成,如下:
Driver Class Name: weblogic.jdbc.sqlserver.SQLServerDriverURL:jdbc:bea:sqlserver://localhost:1433Properties: user=sa
portNumber=1433
databaseName=kkmisdb
serverName=localhost然后测试,错误提示如下:Messages Connection test failed.
[BEA][SQLServer JDBC Driver]Error establishing socket to host and port: localhost:1433. Reason: Connection refused: connect<br/>weblogic.jdbc.base.BaseExceptions.createException(Unknown Source)<br/>weblogic.jdbc.base.BaseExceptions.getException(Unknown Source)<br/>weblogic.jdbc.sqlserver.tds.TDSConnection.<init>(Unknown Source)<br/>weblogic.jdbc.sqlserver.SQLServerImplConnection.open(Unknown Source)<br/>weblogic.jdbc.base.BaseConnection.connect(Unknown Source)<br/>weblogic.jdbc.base.BaseConnection.setupImplConnection(Unknown Source)<br/>weblogic.jdbc.base.BaseConnection.open(Unknown Source)<br/>weblogic.jdbc.base.BaseDriver.connect(Unknown Source)<br/>com.bea.console.utils.jdbc.JDBCUtils.testConnection(JDBCUtils.java:493)<br/>com.bea.console.actions.jdbc.datasources.createjdbcdatasource.CreateJDBCDataSource.testConnectionConfiguration(CreateJDBCDataSource.java:364)<br/>sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)<br/>sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)<br/>sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)<br/>java.lang.reflect.Method.invoke(Method.java:585)<br/>org.apache.beehive.netui.pageflow.FlowController.invokeActionMethod(FlowController.java:812)<br/>org.apache.beehive.netui.pageflow.FlowController.getActionMethodForward(FlowController.java:751)<br/>org.apache.beehive.netui.pageflow.FlowController.internalExecute(FlowController.java:434)<br/>org.apache.beehive.netui.pageflow.PageFlowController.internalExecute(PageFlowController.java:245)<br/>org.apache.beehive.netui.pageflow.FlowController.execute(FlowController.java:316)<br/>org.apache.beehive.netui.pageflow.internal.FlowControllerAction.execute(FlowControllerAction.java:48)<br/>...
数据库配置应该没有问题的,程序代码也应该没问题,在WEBLOGIC6.1下面都可以用的,以前的服务器是用PC机的,现在顶不住了,准备移植到新的服务器上,用WEBLOGIC9.0。帮忙看看,谢谢!
总是出现命名没有找到.jndi的名字就是找不到.
我在配置完data source时点那个测试按钮都通过了,可以程序里写就是找不到.
郁闷,三天了呀.
Context ctx = new InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource) ctx.lookup ("kksource");
试一下.
并确认你在建完连接池后点那个测试按钮成功.