Java DataSource myDataSource(String username, String password)

Here you can find the source of myDataSource(String username, String password)

Description

my Data Source

License

Open Source License

Declaration

public static DataSource myDataSource(String username, String password) throws SQLException 

Method Source Code

//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;
    }
}

Related

  1. initializeDataSource()
  2. isDataSourceAvailable(String dataSourceName)
  3. logQueryResultToFile(DataSource dataSource, String path, String sqlStatement, Object... boundVariables)
  4. lookupDataSource(String dataSourceName)
  5. lookupDataSource(String dataSourceName, final Hashtable jndiProperties)
  6. purgeTables(DataSource ds)
  7. registerSpringDataSource(String name, DataSource dataSource)
  8. selectCount(DataSource ds, String tableName)
  9. setUpJndiDatasource()