Package javax.sql

Examples of javax.sql.DataSource


        ("org.pentaho.reporting.engine.classic.extensions.datasources.mondrian.CacheJndiDataSources"));
    if (cacheEnabled)
    {
      synchronized (map)
      {
        final DataSource o1 = (DataSource) map.get(connectionPath);
        if (o1 != null)
        {
          return o1;
        }
      }
View Full Code Here


     *
     * @return a DBUnit database connection (wrapped)
     */
    protected IDatabaseConnection getConnection() {
        try {
            DataSource datasource = ((DataSource)new InitialContext().lookup(datasourceJndiName));

            // Get a JDBC connection from JNDI datasource
            Connection con = datasource.getConnection();
            IDatabaseConnection dbUnitCon = new DatabaseConnection(con);
            editConfig(dbUnitCon.getConfig());
            return dbUnitCon;
        } catch (Exception ex) {
            throw new RuntimeException(ex);
View Full Code Here

  public OlapConnection createConnection(final String user, final String password) throws SQLException
  {
    try
    {
      final Context ctx = getInitialContext();
      final DataSource ds = findDataSource(ctx, connectionPath);

      final String realUser;
      final String realPassword;
      if (username != null)
      {
        realUser = username;
      }
      else
      {
        realUser = user;
      }
      if (this.password != null)
      {
        realPassword = this.password;
      }
      else
      {
        realPassword = password;
      }

      if (realUser == null)
      {
        final Connection connection = ds.getConnection();
        if (connection == null)
        {
          throw new SQLException("JNDI DataSource is invalid; it returned null without throwing a meaningful error.");
        }
        if (connection instanceof OlapConnection)
        {
          return (OlapConnection) connection;
        }
        if (connection instanceof OlapWrapper)
        {
          final OlapWrapper wrapper = (OlapWrapper) connection;
          return wrapper.unwrap(OlapConnection.class);
        }
        throw new SQLException("Unable to unwrap the connection: " + connectionPath); //$NON-NLS-1$
      }

      final Connection connection = ds.getConnection(realUser, realPassword);
      if (connection == null)
      {
        throw new SQLException("JNDI DataSource is invalid; it returned null without throwing a meaningful error.");
      }
      if (connection instanceof OlapConnection)
View Full Code Here

 
  public static void export(FacesContext facesContext, String jndiDataSourceName, String reportsDirectoryPath, String reportFileName, String outputFileName, ReportType type, HashMap params) throws JRException, NamingException, SQLException, Exception
  {
    String retMessage = "OK";
    Context initContext = new InitialContext();
    DataSource dataSource = (DataSource) initContext.lookup(jndiDataSourceName);
    Connection conn = dataSource.getConnection();

    if (!reportsDirectoryPath.endsWith(File.separator))
      reportsDirectoryPath += File.separator;

    Locale currentLocale = new java.util.Locale("it", "IT");
View Full Code Here

*/
public class TestTooManyCursors extends DBITestCase
{
    public void testFoo() throws Exception
    {
        DataSource ds = Tools.getDataSource();
        DataSource dataSource = new ErrorProducingDataSource(ds, 99);
        IDBI dbi = new DBI(dataSource);

        try {
            dbi.withHandle(new HandleCallback<Object>()
            {
View Full Code Here

      if ( initialContext == null ) {
        fLogger.severe(
          "DataSource problem. InitialContext is null. Db : " + Util.quote(dbConnString)
        );
      }
      DataSource datasource = (DataSource)initialContext.lookup(dbConnString);
      if ( datasource == null ){
        fLogger.severe("Datasource is null for : " + dbConnString);
      }
      result = datasource.getConnection();
    }
    catch (NamingException ex){
      throw new DAOException(
        "Config error with JNDI and datasource, for db " + Util.quote(dbConnString), ex
      );
View Full Code Here

        {
            pe.printStackTrace();
            throw new DatastorePoolException("Proxool", dbDriver, dbURL, pe);
        }

        DataSource ds = new org.logicalcobwebs.proxool.ProxoolDataSource(alias);

        return ds;
    }
View Full Code Here

        {
            throw new DatastorePoolException("DBCP", dbDriver, dbURL, e);
        }

        // Create the datasource
        DataSource ds = new org.datanucleus.store.rdbms.datasource.dbcp.PoolingDataSource(connectionPool);

        return ds;
    }
View Full Code Here

        {
            throw new DatastorePoolException("DBCP", dbDriver, dbURL, e);
        }

        // Create the datasource
        DataSource ds = new org.apache.commons.dbcp.PoolingDataSource(connectionPool);

        return ds;
    }
View Full Code Here

     * @return The JDBC DataSource for this servlet instance.
     */
    protected static DataSource getDataSource(ServletConfig config)
            throws ServletException {

        DataSource dataSource;

        String dataSourceName = config.getInitParameter(INIT_PARAM_DATA_SOURCE);
        if (dataSourceName == null) {
            dataSourceName = config.getServletContext().getInitParameter(
                    CONTEXT_PARAM_DATA_SOURCE);
View Full Code Here

TOP

Related Classes of javax.sql.DataSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.