Package org.apache.derby.jdbc

Examples of org.apache.derby.jdbc.EmbeddedDataSource


    public static void testDSRequestAuthentication() throws SQLException {

        if (usingDerbyNetClient())
            return;
       
        EmbeddedDataSource ds = new EmbeddedDataSource();

        // DataSource - EMPTY
        dsConnectionRequests(new String[] { 
             "XJ004","XJ004","XJ004","XJ004",
             "XJ004","XJ004","XJ004","XJ004","XJ004"}, ds);
        // DataSource - connectionAttributes=databaseName=wombat");
        ds.setConnectionAttributes("databaseName=" + dbName);
        dsConnectionRequests(new String[] { 
            "XJ004","XJ004","XJ004","XJ004",
            "XJ004","XJ004","XJ004","XJ004","XJ004"}, ds);
        ds.setConnectionAttributes(null);

        // DataSource - attributesAsPassword=true");
        ds.setAttributesAsPassword(true);
        dsConnectionRequests(new String[] { 
            "XJ004","XJ004","XJ004","XJ028",
            "XJ028","XJ004","XJ004","XJ004","XJ004"}, ds);
        ds.setAttributesAsPassword(false);

        // DataSource - attributesAsPassword=true,
        // connectionAttributes=databaseName=kangaroo");
        ds.setAttributesAsPassword(true);
        ds.setConnectionAttributes("databaseName=kangaroo");
        dsConnectionRequests(new String[] { 
            "XJ004","XJ004","XJ004","XJ028",
            "XJ028","XJ004","XJ004","XJ004","XJ004"}, ds);
        ds.setAttributesAsPassword(false);
        ds.setConnectionAttributes(null);

        // Enable Authentication;

        setDatabaseProperty("derby.user.fred", "wilma");
        setDatabaseProperty("derby.user.APP", "APP");
        setDatabaseProperty("derby.authentication.provider", "BUILTIN");
        setDatabaseProperty("derby.connection.requireAuthentication", "true");
       
        ds.setShutdownDatabase("shutdown");
        try {
            ds.getConnection();
        } catch (SQLException sqle) {
            assertSQLState("XJ015", sqle);
        }

        ds.setDatabaseName(null);
        ds.setShutdownDatabase(null);

        // "AUTHENTICATION NOW ENABLED");

        // DataSource - attributesAsPassword=true
        ds.setAttributesAsPassword(true);
        dsConnectionRequests(new String[] { 
            "XJ004","XJ004","XJ004","XJ028",
            "XJ028","XJ004","XJ004","XJ004","XJ004"}, ds);
        ds.setAttributesAsPassword(false);

        // ensure the DS property password is not treated as a set of
        // attributes.
        // DataSource - attributesAsPassword=true, user=fred,
        //     password=databaseName=wombat;password=wilma
        ds.setAttributesAsPassword(true);
        ds.setUser("fred");
        ds.setPassword("databaseName=" + dbName + ";password=wilma");
        dsConnectionRequests(new String[] { 
            "XJ004","XJ004","XJ004","XJ028",
            "XJ028","XJ004","XJ004","XJ004","XJ004"}, ds);
        ds.setAttributesAsPassword(false);
        ds.setUser(null);
        ds.setPassword(null);
        ds = null;

        // now with ConnectionPoolDataSource
        EmbeddedConnectionPoolDataSource cpds = new EmbeddedConnectionPoolDataSource();
        // ConnectionPoolDataSource - EMPTY
View Full Code Here


                // name conflict!!!
            }
            System.setProperty( "derby.system.home", derbyDir.getAbsolutePath() );
            driverName = "org.apache.derby.jdbc.EmbeddedDriver";
            dbUrl = "jdbc:derby:photovault;create=true";
            EmbeddedDataSource derbyDs = new EmbeddedDataSource();
            derbyDs.setDatabaseName( "photovault" );
            derbyDs.setCreateDatabase( "create" );
            ds = derbyDs;
        } else {
       
            MysqlDataSource mysqlDs = new MysqlDataSource();
            mysqlDs.setURL( dbUrl );
View Full Code Here

    return s;

  }
  public javax.sql.DataSource getDS(String database, String user, String password) {
   
    EmbeddedDataSource ds = new EmbeddedDataSource();
    ds.setDatabaseName(database);
    if (user != null) {
      ds.setUser(user);
      ds.setPassword(password);
    }

    return ds;
  }
View Full Code Here

            try {
                DriverManager.getConnection(_dbUrl).close();
            } catch (SQLException se) {
                __log.error(se);
            }
            EmbeddedDataSource dds = new EmbeddedDataSource();
            dds.setDatabaseName("memory:" + _dbName);
            dds.setUser("sa");
            dds.setCreateDatabase("true");
            _datasource = dds;
        } else {
            _dbUrl = "jdbc:derby:" + _workRoot + File.separator + _dbName;
            if (_odeConfig.isDbEmbeddedCreate()) {
                _dbUrl += ";create=true";
View Full Code Here

         loginService.setCacheMs(__cacheInterval);
         if (_testServer != null)
             loginService.setServer(_testServer.getServer());
        
         //create a datasource
         EmbeddedDataSource ds = new EmbeddedDataSource();
         File db = new File (DatabaseLoginServiceTestServer.getDbRoot(), "loginservice");
         ds.setDatabaseName(db.getAbsolutePath());
         org.eclipse.jetty.plus.jndi.Resource binding = new org.eclipse.jetty.plus.jndi.Resource(null, "dstest",
                                                                                                      ds);
         assertThat("Created binding for dstest", binding, notNullValue());
         return loginService;
     }
View Full Code Here

    s.close();
  }

  private static void testDSRequestAuthentication() throws SQLException {

    EmbeddedDataSource ds = new EmbeddedDataSource();

    System.out.println("DataSource - EMPTY");
    dsConnectionRequests(ds);

    System.out.println("DataSource - connectionAttributes=databaseName=wombat");
    ds.setConnectionAttributes("databaseName=wombat");
    dsConnectionRequests(ds);
    ds.setConnectionAttributes(null);

    System.out.println("DataSource - attributesAsPassword=true");
    ds.setAttributesAsPassword(true);
    dsConnectionRequests(ds);
    ds.setAttributesAsPassword(false);

    System.out.println("DataSource - attributesAsPassword=true, connectionAttributes=databaseName=kangaroo");
    ds.setAttributesAsPassword(true);
    ds.setConnectionAttributes("databaseName=kangaroo");
    dsConnectionRequests(ds);
    ds.setAttributesAsPassword(false);
    ds.setConnectionAttributes(null);

    System.out.println("Enable Authentication");
    ds.setDatabaseName("wombat");
    Connection cadmin = ds.getConnection();
    CallableStatement cs = cadmin.prepareCall("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(?, ?)");
    cs.setString(1, "derby.user.fred");
    cs.setString(2, "wilma");
    cs.execute();

    cs.setString(1, "derby.authentication.provider");
    cs.setString(2, "BUILTIN");
    cs.execute();

    cs.setString(1, "derby.connection.requireAuthentication");
    cs.setString(2, "true");
    cs.execute();

    cs.close();

    cadmin.close();

    ds.setShutdownDatabase("shutdown");
    try {
      ds.getConnection();
    } catch (SQLException sqle) {
      System.out.println(sqle.getSQLState() + ":" + sqle.getMessage() );
    }

    ds.setDatabaseName(null);
    ds.setShutdownDatabase(null);

    System.out.println("AUTHENTICATION NOW ENABLED");

    System.out.println("DataSource - attributesAsPassword=true");
    ds.setAttributesAsPassword(true);
    dsConnectionRequests(ds);
    ds.setAttributesAsPassword(false);

    // ensure the DS property password is not treated as a set of attributes.
    System.out.println("DataSource - attributesAsPassword=true, user=fred, password=databaseName=wombat;password=wilma");
    ds.setAttributesAsPassword(true);
    ds.setUser("fred");
    ds.setPassword("databaseName=wombat;password=wilma");
    dsConnectionRequests(ds);
    ds.setAttributesAsPassword(false);
    ds.setUser(null);
    ds.setPassword(null);
    ds = null;

    // now with ConnectionPoolDataSource
    EmbeddedConnectionPoolDataSource cpds = new EmbeddedConnectionPoolDataSource();
    System.out.println("ConnectionPoolDataSource - EMPTY");
View Full Code Here

  }

  public void testJira95ds(Connection conn, String dbName) throws SQLException
  {
    System.out.print("\ntesting jira 95 for DataSource");
    EmbeddedDataSource ds = new EmbeddedDataSource();
    ds.setDatabaseName(dbName);
    Connection conn1 = ds.getConnection();
    conn1.close();
  }
View Full Code Here

     * It attempts to recreate the tables everytime the test is executed.
     *
     * @return PersistenceAdapter - persistence adapter.
     */
    protected PersistenceAdapter createPersistenceAdapter() {
        EmbeddedDataSource ds = new EmbeddedDataSource();
        ds.setDatabaseName("testdb");
        if (!init) {
            ds.setCreateDatabase("create");
        }

        JDBCPersistenceAdapter persistenceAdapter = new JDBCPersistenceAdapter(ds, new DefaultWireFormat());

        if (!init) {
View Full Code Here

    private static final transient Log LOG = LogFactory.getLog(DbRestartJDBCQueueMasterSlaveTest.class);
   
    protected void messageSent() throws Exception {   
        if (++inflightMessageCount == failureCount) {
            LOG.info("STOPPING DB!@!!!!");
            final EmbeddedDataSource ds = getExistingDataSource();
            ds.setShutdownDatabase("shutdown");
            LOG.info("DB STOPPED!@!!!!");
           
            Thread dbRestartThread = new Thread("db-re-start-thread") {
                public void run() {
                    LOG.info("Waiting for master broker to Stop");
                    master.waitUntilStopped();
                    ds.setShutdownDatabase("false");
                    LOG.info("DB RESTARTED!@!!!!");
                }
            };
            dbRestartThread.start();
        }
View Full Code Here

        // Setup the Derby datasource.
        System.setProperty("derby.system.home", getDataDirectoryFile().getCanonicalPath());
        System.setProperty("derby.storage.fileSyncTransactionLog", "true");
        System.setProperty("derby.storage.pageCacheSize", "100");

        final EmbeddedDataSource ds = new EmbeddedDataSource();
        ds.setDatabaseName("derbydb");
        ds.setCreateDatabase("create");
        return ds;
    }
View Full Code Here

TOP

Related Classes of org.apache.derby.jdbc.EmbeddedDataSource

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.