Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Application Server  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 高手帮帮忙 看一下 (jb8+webligic7 java.net.ConnectException: http://lht:7001: Destination unreachable
lht_java



发贴: 0
积分: 0
于 2003-08-15 10:09 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
original subject: 高手帮帮忙啊,请看一下,实在不知道什么原因了,小弟这里表示感谢了

我用的环境是jb8+webligic7,配置没有问题,都通过了,我用的数据库是jb8中自带的,但没有对监听进行注册。

以下是我得程序:
package jdbcexample;
import java.sql.*;
import javax.naming.*;
import javax.sql.*;
import java.util.Properties;
import javax.rmi.PortableRemoteObject;

public class Example1 {

public static void main(String[] args) {
DataSource ds = null;
Context ctx = null;
Connection myConn = null;
try {
/* 获得WebLogic ServerJNDI初始上下文信息
*/
ctx = getInitialContext();
/* 建立数据源对象
*/
ds = (javax.sql.DataSource)
ctx.lookup("myDataSource");
}
catch (Exception E) {
System.out.println("Init Error: " + E);
}
Statement myStatement=null;
ResultSet myResultSet=null;
try {
//建立连接
myConn = ds.getConnection();
// 建立语句对象
myStatement = myConn.createStatement();
//建立结果集对象
myResultSet = myStatement.executeQuery(
"SELECT full_name from employee"
);
//遍历结果集对象,访问每一条记录,输出full_name字段
while(myResultSet.next())
{
System.out.println("the employee full name is " + myResultSet.getString("full_name"));
}
//关闭结果集
myResultSet.close();
}
catch (SQLException e) {
System.out.println("Error code = " + e.getErrorCode());
System.out.println("Error message = " + e.getMessage());
}
finally {
try {
// close the Statement object using the close() method
if (myStatement != null) {
myStatement.close();
}
// close the Connection object using the close() method
if (myConn != null) {
myConn.close();
}
}
catch (SQLException e) {
System.out.println("Error code = " + e.getErrorCode());
System.out.println("Error message = " + e.getMessage());
}
}

}
private static Context getInitialContext() throws Exception {
String url = "http://lht:7001";
String user = "example";
String password = "";
Properties properties = null;
try {
properties = new Properties();
properties.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
properties.put(Context.PROVIDER_URL, url);
if (user != null) {
properties.put(Context.SECURITY_PRINCIPAL, user);
properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
}
return new InitialContext(properties);
}
catch(Exception e) {
throw e;
}
}

}

编译好使,但运行时出现错误:关键事《》中的部分不知道什么缘故

D:\JBuilder8\jdk1.4\bin\javaw -classpath "D:\weblogic_源代码\第4章\jdbcexample\classes;D:\bea\weblogic700\server\lib\weblogic.jar;D:\bea\weblogic700\server\lib\webservices.jar;D:\JBuilder8\jdk1.4\demo\jfc\Java2D\Java2Demo.jar;D:\JBuilder8\jdk1.4\demo\plugin\jfc\Java2D\Java2Demo.jar;D:\JBuilder8\jdk1.4\jre\lib\charsets.jar;D:\JBuilder8\jdk1.4\jre\lib\ext\dnsns.jar;D:\JBuilder8\jdk1.4\jre\lib\ext\ldapsec.jar;D:\JBuilder8\jdk1.4\jre\lib\ext\localedata.jar;D:\JBuilder8\jdk1.4\jre\lib\ext\sunjce_provider.jar;D:\JBuilder8\jdk1.4\jre\lib\im\indicim.jar;D:\JBuilder8\jdk1.4\jre\lib\jaws.jar;D:\JBuilder8\jdk1.4\jre\lib\jce.jar;D:\JBuilder8\jdk1.4\jre\lib\jsse.jar;D:\JBuilder8\jdk1.4\jre\lib\rt.jar;D:\JBuilder8\jdk1.4\jre\lib\sunrsasign.jar;D:\JBuilder8\jdk1.4\lib\dt.jar;D:\JBuilder8\jdk1.4\lib\htmlconverter.jar;D:\JBuilder8\jdk1.4\lib\tools.jar" jdbcexample.Example1
《《 java.lang.NullPointerExceptionInit Error: javax.naming.CommunicationException [Root exception is java.net.ConnectException: http://lht:7001: Destination unreachable; nested exception is:
  java.net.ProtocolException: Tunneling result unspecified - is the HTTP server at host: 'lht' and port: '7001' a WebLogic Server?; No available router to destination] 》》
  at jdbcexample.Example1.main(Example1.java:30)
Exception in thread "main"


why edited on 2003-08-19 10:22

作者 Re:高手帮帮忙啊,请看一下,实在不知道什么原因了,小弟这里表示感谢了 [Re:lht_java]
enoch





发贴: 35
积分: 20
于 2003-08-15 17:21 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list

String url = "http://lht:7001";

改成
String url = "t3://lht:7001";

试试




作者 Re:高手帮帮忙啊,请看一下,实在不知道什么原因了,小弟这里表示感谢了 [Re:lht_java]
lht_java



发贴: 0
积分: 0
于 2003-08-15 20:44 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
谢谢了,朋友你真好,我在试试看吧

好像是还不行啊,

我配置了,而且也没有提示错误啊,但不知道为什么在jb中就是不行,我用的是jb8,是不是jb中还有其他的配置啊,郁闷死了,都三天了,一点进展没有,要崩溃了



作者 Re:高手帮帮忙啊,请看一下,实在不知道什么原因了,小弟这里表示感谢了 [Re:lht_java]
nothing

天外飞仙.....

CJSDN高级会员


发贴: 1636
积分: 131
于 2003-08-15 20:50 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
改lht:7001为localhost:7001 或127.0.0.1:7001试试



躲得过的怪物,躲不过的刺激

作者 Re:高手帮帮忙啊,请看一下,实在不知道什么原因了,小弟这里表示感谢了 [Re:lht_java]
chenyajun5

一日不倒,每天都打

CJSDN高级会员


发贴: 643
积分: 90
于 2003-08-15 21:07 user profilesend a private message to usersend email to chenyajun5search all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
先看Borland的白皮书:
http://bdn.borland.com/article/images/29528/ejbdevjbweblogic.pdf



想干的人找一个方法,不想干的人找一个借口。
作者 Re:高手帮帮忙啊,请看一下,实在不知道什么原因了,小弟这里表示感谢了 [Re:lht_java]
lht_java



发贴: 0
积分: 0
于 2003-08-16 10:09 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
谢谢各位的给予支持,我在看看吧,

我的qq号是 47669498 最后一只烟

我很想和各位进行交流一起学习j2ee ,如果那位有兴趣我们可以来找我




flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923