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


话题树型展开
人气 标题 作者 字数 发贴时间
7125 高手帮帮忙 看一下 (jb8+webligic7 java.net.ConnectException: http://lht:7001: Destination unreachable lht_java 3880 2003-08-15 10:09
5520 Re:高手帮帮忙啊,请看一下,实在不知道什么原因了,小弟这里表示感谢了 enoch 99 2003-08-15 17:21
5223 Re:高手帮帮忙啊,请看一下,实在不知道什么原因了,小弟这里表示感谢了 lht_java 108 2003-08-15 20:44
5840 Re:高手帮帮忙啊,请看一下,实在不知道什么原因了,小弟这里表示感谢了 nothing 42 2003-08-15 20:50
5555 Re:高手帮帮忙啊,请看一下,实在不知道什么原因了,小弟这里表示感谢了 chenyajun5 80 2003-08-15 21:07
5469 Re:高手帮帮忙啊,请看一下,实在不知道什么原因了,小弟这里表示感谢了 lht_java 80 2003-08-16 10:09

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