Package org.apache.derby.jdbc

Examples of org.apache.derby.jdbc.EmbeddedDataSource


    protected BrokerService createBroker() throws Exception {

        BrokerService broker = new BrokerService();
        jdbc = new BrokenPersistenceAdapter();

        dataSource = new EmbeddedDataSource();
        dataSource.setDatabaseName("target/derbyDb");
        dataSource.setCreateDatabase("create");

        jdbc.setDataSource(dataSource);
        jdbc.setUseLock(false);
View Full Code Here


    @Override
    public Connector createConnector() throws Exception
    {
        JdbcConnector c = new JdbcConnector(muleContext);
        EmbeddedDataSource embeddedDS = new EmbeddedDataSource();
        embeddedDS.setDatabaseName(DATABASE_NAME);
        c.setName("JdbcConnector");
        c.setDataSource(embeddedDS);
        c.setPollingFrequency(1000);
        return c;
    }
View Full Code Here

        System.setProperty("derby.storage.fileSyncTransactionLog", "true");

        // load the Embedded driver to initialize the home
        new org.apache.derby.jdbc.EmbeddedDriver();

        EmbeddedDataSource datasource = new EmbeddedDataSource();
        datasource.setDatabaseName("SystemDatabase");
        datasource.setCreateDatabase("create");
        try {
            Connection c = datasource.getConnection();
            c.close();
        } catch (SQLException e) {
            while (e.getNextException() != null) {
                e.printStackTrace();
                e = e.getNextException();
View Full Code Here

        // Setup the Derby datasource.
        System.setProperty("derby.system.home", dataDirectory.getCanonicalPath());
        System.setProperty("derby.storage.fileSyncTransactionLog", "true");
       
        EmbeddedDataSource ds = new EmbeddedDataSource();
        ds.setDatabaseName("derbydb");
        ds.setCreateDatabase("create");       
        JDBCPersistenceAdapter jdbcAdapter = new JDBCPersistenceAdapter();
        jdbcAdapter.setDataSource(ds);
       
        // Setup the Journal
        File journalDir = new File(dataDirectory, "journal");
View Full Code Here

    checkConnection("DriverManager ", dmc);
    checkJBMSToString();


    EmbeddedDataSource dscs = new EmbeddedDataSource();
    dscs.setDatabaseName("wombat");
    checkToString(dscs);

    DataSource ds = dscs;

    checkConnection("EmbeddedDataSource", ds.getConnection());
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

    @Override
  public void destroy() throws Exception {
    logger.info("Attempting Derby database shut down on: " + dataSource);
    if (!isShutdown && dataSource != null
        && dataSource instanceof EmbeddedDataSource) {
      EmbeddedDataSource ds = (EmbeddedDataSource) dataSource;
      try {
        ds.setShutdownDatabase("shutdown");
        ds.getConnection();
      } catch (SQLException except) {
        if (except.getSQLState().equals("08006")) {
          // SQLState derby throws when shutting down the database
          logger.info("Derby database is now shut down.");
          isShutdown = true;
View Full Code Here

    File directory = new File(dataDirectory);
    System.setProperty("derby.system.home", directory.getCanonicalPath());
    System.setProperty("derby.storage.fileSyncTransactionLog", "true");
    System.setProperty("derby.storage.pageCacheSize", "100");

    final EmbeddedDataSource ds = new EmbeddedDataSource();
    ds.setDatabaseName("derbydb");
    ds.setCreateDatabase("create");

    logger.info("Created instance of " + ds.toString());
   
    return ds;
  }
View Full Code Here

    File directory = new File(dataDirectory);
    System.setProperty("derby.system.home", directory.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.