Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.JdbcTemplate.execute()


        for (String idx : indexes.stringPropertyNames()) {
            LOG.debug("Creating index {}", indexes.get(idx).toString());

            try {
                jdbcTemplate.execute(indexes.get(idx).toString());
            } catch (DataAccessException e) {
                LOG.error("Could not create index ", e);
            }
        }
View Full Code Here


        for (String idx : views.stringPropertyNames()) {
            LOG.debug("Creating view {}", views.get(idx).toString());

            try {
                jdbcTemplate.execute(views.get(idx).toString().replaceAll("\\n", " "));
            } catch (DataAccessException e) {
                LOG.error("Could not create view ", e);
            }
        }
View Full Code Here

   */
  public static void loadFunction(JdbcTemplateDao dao, PostgreSQLFunction dbFunction) throws ApplicationException {
    JdbcTemplate jdbcTemplate = dao.getJdbcTemplate();

    // initialize drop procedure, if database has been dropped
    jdbcTemplate.execute(new ResourceUtil(DROP_FUNCTION.getURI()).getContent());

    // drop previous function version, if necessary
    jdbcTemplate.queryForInt("select util.drop_function( ?,? )",
        dbFunction.getSchema(), dbFunction.getFunctionName());

View Full Code Here

    // drop previous function version, if necessary
    jdbcTemplate.queryForInt("select util.drop_function( ?,? )",
        dbFunction.getSchema(), dbFunction.getFunctionName());

    // load new function body
    jdbcTemplate.execute(new ResourceUtil(dbFunction.getURI()).getContent());
  }

  public static void loadAllFunctions(JdbcTemplateDao dao) throws ApplicationException {
    for (PostgreSQLFunction dbFunction : PostgreSQLFunction.values()) {
      loadFunction(dao, dbFunction);
View Full Code Here

    }
  }
 
  public static void truncateTables(JdbcTemplateDao dao) throws ApplicationException {
    JdbcTemplate jdbcTemplate = dao.getJdbcTemplate();
    jdbcTemplate.execute("truncate music.artist cascade");
    jdbcTemplate.execute("truncate library.directory cascade");
    jdbcTemplate.execute("truncate music.tag cascade");
    jdbcTemplate.execute("truncate music.lastfmuser cascade");
   
    /*
 
View Full Code Here

  }
 
  public static void truncateTables(JdbcTemplateDao dao) throws ApplicationException {
    JdbcTemplate jdbcTemplate = dao.getJdbcTemplate();
    jdbcTemplate.execute("truncate music.artist cascade");
    jdbcTemplate.execute("truncate library.directory cascade");
    jdbcTemplate.execute("truncate music.tag cascade");
    jdbcTemplate.execute("truncate music.lastfmuser cascade");
   
    /*
     * If we really wanted to truncate all tables, we could do:
View Full Code Here

 
  public static void truncateTables(JdbcTemplateDao dao) throws ApplicationException {
    JdbcTemplate jdbcTemplate = dao.getJdbcTemplate();
    jdbcTemplate.execute("truncate music.artist cascade");
    jdbcTemplate.execute("truncate library.directory cascade");
    jdbcTemplate.execute("truncate music.tag cascade");
    jdbcTemplate.execute("truncate music.lastfmuser cascade");
   
    /*
     * If we really wanted to truncate all tables, we could do:
     * loadFunction(dao, PostgreSQLFunction.TRUNCATE_ALL_TABLES);
View Full Code Here

  public static void truncateTables(JdbcTemplateDao dao) throws ApplicationException {
    JdbcTemplate jdbcTemplate = dao.getJdbcTemplate();
    jdbcTemplate.execute("truncate music.artist cascade");
    jdbcTemplate.execute("truncate library.directory cascade");
    jdbcTemplate.execute("truncate music.tag cascade");
    jdbcTemplate.execute("truncate music.lastfmuser cascade");
   
    /*
     * If we really wanted to truncate all tables, we could do:
     * loadFunction(dao, PostgreSQLFunction.TRUNCATE_ALL_TABLES);
     * jdbcTemplate.execute("select util.truncate_all_tables()");
View Full Code Here

                    createTableSql.append(")");
                } else {
                    createTableSql.append(", ");
                }
            }
            jdbcTemplate.execute(createTableSql.toString());
        }
    }

}
View Full Code Here

    public void afterPropertiesSet() throws Exception {
        //because we're using an in-memory hsqldb for the sample app, a new one will be created each time the
        //app starts, so insert the sample admin user at startup:
        JdbcTemplate jdbcTemplate = new JdbcTemplate(this.dataSource);

        jdbcTemplate.execute("insert into roles values (1, 'user', 'The default role given to all users.')");
        jdbcTemplate.execute("insert into roles values (2, 'admin', 'The administrator role only given to site admins')");
        jdbcTemplate.execute("insert into roles_permissions values (2, 'user:*')");
        jdbcTemplate.execute("insert into users(id,username,email,password) values (1, 'admin', 'sample@shiro.apache.org', '" + new Sha256Hash("admin").toHex() + "')");
        jdbcTemplate.execute("insert into users_roles values (1, 2)");

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.