Java DataSource initializeDataSource()

Here you can find the source of initializeDataSource()

Description

initialize Data Source

License

Apache License

Declaration

public static void initializeDataSource() throws NamingException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

public class Main {
    private static volatile DataSource ussdDatasource = null;

    public static void initializeDataSource() throws NamingException {
        if (ussdDatasource != null) {
            return;
        }// w ww  .  j a  v  a2  s  . c  om

        String statdataSourceName = "jdbc/CONNECT_DB";

        if (statdataSourceName != null) {
            try {
                Context ctx = new InitialContext();
                ussdDatasource = (DataSource) ctx.lookup(statdataSourceName);
            } catch (NamingException e) {
                //log.error(e);
                throw e;
            }

        }
    }
}

Related

  1. getTables(DataSource datasource)
  2. hasTable(DataSource ds, String table)
  3. initDataSource()
  4. initDatasource(String jndiName)
  5. initDb(DataSource ds)
  6. isDataSourceAvailable(String dataSourceName)
  7. logQueryResultToFile(DataSource dataSource, String path, String sqlStatement, Object... boundVariables)
  8. lookupDataSource(String dataSourceName)
  9. lookupDataSource(String dataSourceName, final Hashtable jndiProperties)