Here you can find the source of myDataSource(String username, String password)
public static DataSource myDataSource(String username, String password) throws SQLException
//package com.java2s; //License from project: Open Source License import java.sql.SQLException; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.sql.DataSource; public class Main { public static DataSource myDataSource(String username, String password) throws SQLException { InitialContext cxt;/* w ww . j a v a 2 s. c o m*/ DataSource ds = null; try { cxt = new InitialContext(); ds = (DataSource) cxt.lookup("java:/comp/env/jdbc/scuola247"); } catch (NamingException e) { throw new SQLException(e); } return ds; } }