Package javax.sql

Examples of javax.sql.DataSource


      PreparedStatement ps = null;
      ResultSet rs = null;

      try {
        InitialContext ctx = new InitialContext();
        DataSource ds = (DataSource) ctx.lookup(dsJndiName);
        conn = ds.getConnection();
        // prepare the query
        ps = conn.prepareStatement(principalsQuery);
        ps.setString(1, username);
        rs = ps.executeQuery();
        if (rs.next()) {
View Full Code Here


             int acquireIncrement,
             int maxIdleTime,
             int maxStatements,
             String factoryLocation ) throws SQLException
    {
  DataSource nested = DriverManagerDataSourceFactory.create( jdbcDriverClass,
                   jdbcUrl,
                   user,
                   password );
  return createReferenceable( nested,
            minPoolSize,
View Full Code Here

             String user,
             String password,
             String factoryLocation )
  throws SQLException
    {
  DataSource nested = DriverManagerDataSourceFactory.create( jdbcDriverClass,
                   jdbcUrl,
                   user,
                   password );
  return createReferenceable( nested,
            factoryLocation );
View Full Code Here

             int acquireIncrement,
             int maxIdleTime,
             int maxStatements)
  throws SQLException
    {
  DataSource nested = DriverManagerDataSourceFactory.create( jdbcDriverClass,
                   jdbcUrl,
                   user,
                   password );
  return createSerializable( nested,
           minPoolSize,
View Full Code Here

             String jdbcUrl,
             String user,
             String password)
  throws SQLException
    {
  DataSource nested = DriverManagerDataSourceFactory.create( jdbcDriverClass,
                   jdbcUrl,
                   user,
                   password );
  return createSerializable( nested );
    }
View Full Code Here

                    ConnectionPoolDataSource checkDs1 = apbds.getConnectionPoolDataSource();
                    if (checkDs1 instanceof WrapperConnectionPoolDataSource)
                    {
                        WrapperConnectionPoolDataSource wcheckDs1 = (WrapperConnectionPoolDataSource) checkDs1;
                        wcheckDs1.setFactoryClassLocation( val );
                        DataSource checkDs2 = wcheckDs1.getNestedDataSource();
                        if (checkDs2 instanceof DriverManagerDataSource)
                            ((DriverManagerDataSource) checkDs2).setFactoryClassLocation( val );
                    }
                    return;
                }
View Full Code Here

    // bind our DataSource to.
    String jndiName = argv[0];

      // acquire the DataSource using default pool params...
      // this is the only c3p0 specific code here
    DataSource unpooled = DataSources.unpooledDataSource("jdbc:postgresql://localhost/test",
                     "swaldman",
                     "test");
    DataSource pooled = DataSources.pooledDataSource( unpooled );

    // Create an InitialContext, and bind the DataSource to it in
    // the usual way.
    //
    // We are using the no-arg version of InitialContext's constructor,
View Full Code Here

    // therefore, the jndi environment must be first set via a jndi.properties
    // file, System properties, or by some other means.
    InitialContext ctx = new InitialContext();

    // acquire the DataSource... this is the only c3p0 specific code here
    DataSource ds = (DataSource) ctx.lookup( jndiName );

    // get hold of a Connection an do stuff, in the usual way
    Connection con  = null;
    Statement  stmt = null;
    ResultSet  rs   = null;
    try
        {
      con = ds.getConnection();
      stmt = con.createStatement();
      rs = stmt.executeQuery("SELECT * FROM foo");
      while (rs.next())
          System.out.println( rs.getString(1) );
        }
View Full Code Here

      {
    // Note: your JDBC driver must be loaded [via Class.forName( ... ) or -Djdbc.properties]
    // prior to acquiring your DataSource!

    // Acquire the DataSource... this is the only c3p0 specific code here
    DataSource unpooled = DataSources.unpooledDataSource("jdbc:postgresql://localhost/test",
                     "swaldman",
                     "test");
    DataSource pooled = DataSources.pooledDataSource( unpooled );



    // get hold of a Connection an do stuff, in the usual way
    Connection con  = null;
    Statement  stmt = null;
    ResultSet  rs   = null;
    try
        {
      con = pooled.getConnection();
      stmt = con.createStatement();
      rs = stmt.executeQuery("SELECT * FROM foo");
      while (rs.next())
          System.out.println( rs.getString(1) );
        }
View Full Code Here

    {
  if (cachedInner != null)
      return cachedInner;
  else
      {
    DataSource out = dereference();
    if (this.isCaching())
        cachedInner = out;
    return out;
      }
    }
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.