请求帮忙!
在用weblogic连接池访问数据库时出现错误
程序如下:
import javax.naming.*;
import javax.naming.NamingException;
import java.sql.*;
import javax.sql.DataSource;
class pool
{
public static void main(String args[])
{
DataSource myds=null;
try
{
InitialContext myct=new InitialContext();
myds=(javax.sql.DataSource)myct.lookup("oraclepoolds");
System.out.println("ads");
Connection conn=myds.getConnection();
Statement myst=conn.createStatement();
ResultSet rs=myst.executeQuery("select * from emp");
System.out.println("ads");
while(rs.next())
{
System.out.println(rs.getString("EMANE"));
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
出错信息如下:
javax.naming.NoInitialContextException: Need to specify class name in environmen
t or system property, or as an applet parameter, or in an application resource f
ile: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
43)
at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246
)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
a:283)
at javax.naming.InitialContext.lookup(InitialContext.java:350)
at pool.main(pool.java:14)
问题点数:0、回复次数:2Top
1 楼zez(思恩 闭关练功ing...)回复于 2003-06-03 13:53:18 得分 0
Hashtable ht = new Hashtable();
ht.put(ctx.PROVIDER_URL, "t3://ip:port")
ht.put(ctx.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ctx = new InitialContext(ht);Top
2 楼chenwg168(aa)回复于 2003-06-03 14:15:01 得分 0
zez(思恩 为老婆多挣钱 QQ:883004)
谢谢!
怎么给分呢!?Top



