try
{
Context context=new InitalContext();
Context envCtx=(Contet)context.lookup("java:comp/env");
ds=(DataSource)envCtx.lookup("jdbc/bn");
if(ds!null)
{
out.println("已经获得DataSource!");
Connection conn=ds.getConnection();
Statement stmt=conn.createStatement();
ResultSet rst=stmt.executeQuery("select * from X");
out.print("已下是从数据库读出来的数据");
while(rs.next())
{
out.println(rst.getString("username"));
}
}
else
out.println("连接失败");
}
catch(Exception ne)
{
out.print(ne)
}