Examples of JuConnUtil


Examples of ch.inftec.ju.db.JuConnUtil

      }

      if (!createdSchemas.contains(schemaName) && !StringUtils.isEmpty(adminPassword)) {
        String adminProfile = profile + "Admin";
        logger.info("Admin-Profile defined: {}. Creating Schema '{}' if necessary", adminProfile, schemaName);
        JuConnUtil adminConnUtil = JuConnUtils.build()
            .profile(adminProfile)
            .create();

        // Check if the Schema exists and if we should delete it if so
        boolean createSchema = true;
        if (adminConnUtil.getMetaDataInfo().getSchemaInfos().getSchemaNames().contains(schemaName)) {
          boolean dropExistingSchema = JuUtils.getJuPropertyChain().get(
              String.format("ju-dbutil-test.%s.dropExistingSchema", adminProfile), Boolean.class, "false");

          if (dropExistingSchema) {
            logger.info("Schema {} already exists. Dropping and recreating.", schemaName);
            List<SchemaInfo> schemaInfos = adminConnUtil.getMetaDataInfo().getSchemaInfos()
                .getSchemaInfos(schemaName, null);
            Assert.assertEquals("Catalogs not supported yet", 1, schemaInfos.size());

            if (adminConnUtil.getDbType() == DbType.MYSQL) {
              // For MySQL, drop the user as well
              adminConnUtil.getDbHandler().dropSchema(schemaInfos.get(0), userName);
            } else {
              adminConnUtil.getDbHandler().dropSchema(schemaInfos.get(0));
            }
          } else {
            createSchema = false;
            logger.info(
                "Schema {} already exists. Skipping creation. Set dropExistingSchema for adminProfile to true if Schema should be dropped and recreated.",
                schemaName);
          }
        }

        if (createSchema) {
          logger.info("Creating Schema {}", schemaName);

          String schemaPassword = JuUtils.getJuPropertyChain().get(String.format("ju-dbutil-test.%s.password", profile), false);
          boolean jtaRecoveryGrants = JuUtils.getJuPropertyChain().get(
              String.format("ju-dbutil-test.%s.jtaRecoveryGrants", profile), Boolean.class, "false");
         
          adminConnUtil.getDbHandler().createSchema()
              .name(schemaName)
              .user(userName) // Ignored for DBs that don't have users
              .password(schemaPassword)
              .jtaRecoveryGrants(jtaRecoveryGrants)
              .create();
View Full Code Here

Examples of ch.inftec.ju.db.JuConnUtil

    }
  }
 
  private void assumeTwoDbs() {
    DataSource ds = this.ctx.getBean("jpaDb2DataSource", DataSource.class);
    JuConnUtil connUtil = JuConnUtils.createByDataSource(ds);
    JuAssumeUtils.dbIsNot(connUtil, DbType.MYSQL, DbType.ORACLE);
  }
View Full Code Here

Examples of ch.inftec.ju.db.JuConnUtil

        // Query the table
        Long id = jt.queryForLong("select id from juConnUtilTestTable where id=1");
        Assert.assertEquals(new Long(1), id);
       
        // Create a new connUtil to make sure we'll see the changes there...
        JuConnUtil connUtil2 = JuConnUtils.build()
          .profile(JuUtils.getJuPropertyChain().get("ju-dbutil-test.profile", true))
          .create();
        connUtil2.doWork(new DbWork() {
          @Override
          public void execute(Connection conn) {
            Long id2 = JuConnUtils.asJdbcTemplate(conn).queryForLong("select id from juConnUtilTestTable where id=1");
            Assert.assertEquals(new Long(1), id2);
           
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.