如果jboss的配置都正确的话,这样应该就可以了。InitialContext ctx = new InitialContext();DataSource ds = (DataSource) ctx.lookup("java:DB2DS");con = ds.getConnection();