你再写一个连接数据的类,比如你定义了jndi的名字为jdbc/car,那你写的这个类中定义的jndi的名字也要时jdbc/car;
给你写个简单的例子看看:
jndiName = "java:comp/env/jndi/car";        try {
            Context ctx = new InitialContext();
            DataSource ds = (DataSource) ctx.lookup(jndiName);
           Connection conn = ds.getConnection();
            } catch (NamingException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace;
        }
你要是结贴的话:管理-->输入你的密码-->给分,呵呵