Examples of JdbcTemplate


Examples of org.springframework.jdbc.core.JdbcTemplate

        userTO = createUser(userTO);
        assertNotNull(userTO);
        assertEquals(1, userTO.getResources().size());

        JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);

        String username = jdbcTemplate.queryForObject("SELECT id FROM test WHERE id=?", String.class,
                userTO.getUsername());

        assertEquals(userTO.getUsername(), username);

        UserMod userMod = new UserMod();

        userMod.setId(userTO.getId());
        userMod.addResourceToBeRemoved(RESOURCE_NAME_TESTDB);

        userTO = userService.update(userMod.getId(), userMod);

        assertTrue(userTO.getResources().isEmpty());

        jdbcTemplate.queryForObject("SELECT id FROM test WHERE id=?", String.class, userTO.getUsername());
    }
View Full Code Here

Examples of org.springframework.jdbc.core.JdbcTemplate

        actual = userService.read(actual.getId());
        assertEquals("virattrcache", actual.getVirtualAttributeMap().get("virtualdata").getValues().get(0));

        Exception exception = null;
        try {
            final JdbcTemplate jdbcTemplate = new JdbcTemplate(testDataSource);

            String value = jdbcTemplate.queryForObject(
                    "SELECT USERNAME FROM testsync WHERE ID=?", String.class, actual.getId());
            assertEquals("virattrcache", value);

            jdbcTemplate.update("UPDATE testsync set USERNAME='virattrcache2' WHERE ID=?", userTO.getId());

            value = jdbcTemplate.queryForObject(
                    "SELECT USERNAME FROM testsync WHERE ID=?", String.class, userTO.getId());
            assertEquals("virattrcache2", value);

        } catch (EmptyResultDataAccessException e) {
            exception = e;
View Full Code Here

Examples of org.springframework.jdbc.core.JdbcTemplate

    }

    protected void createIndexes() {
        LOG.debug("Creating indexes");

        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

        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

Examples of org.springframework.jdbc.core.JdbcTemplate

    }

    protected void createViews() {
        LOG.debug("Creating views");

        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

        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

Examples of org.springframework.jdbc.core.JdbcTemplate

    @Autowired
    private UserRequestDAO userRequestDAO;

    private void upgradeActiviti() {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

        List<Map<String, Object>> byteArrays =
                jdbcTemplate.queryForList("SELECT ID_, BYTES_ FROM ACT_GE_BYTEARRAY");
        for (Map<String, Object> row : byteArrays) {
            byte[] updated = new String((byte[]) row.get("BYTES_")).replaceAll(
                    "org\\.apache.syncope\\.core\\.workflow\\.activiti\\.",
                    "org.apache.syncope.core.workflow.user.activiti.task.").
                    replaceAll("org\\.apache\\.syncope\\.client\\.to\\.",
                    "org.apache.syncope.common.to").
                    replaceAll("org\\.apache\\.syncope\\.types\\.",
                    "org.apache.syncope.common.types").
                    replaceAll("org/apache/syncope/types/",
                    "org/apache/syncope/common/types/").
                    getBytes();
            jdbcTemplate.update("UPDATE ACT_GE_BYTEARRAY SET BYTES_=? WHERE ID_=?",
                    new Object[] {updated, row.get("ID_")});
        }
    }
View Full Code Here

Examples of org.springframework.jdbc.core.JdbcTemplate

            }
        }
    }

    private void upgradeReportletConf() {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

        List<Map<String, Object>> rcInstances =
                jdbcTemplate.queryForList("SELECT id, serializedInstance FROM ReportletConfInstance");
        for (Map<String, Object> row : rcInstances) {
            String updated = ((String) row.get("serializedInstance")).
                    replaceAll("org\\.apache\\.syncope\\.client\\.report\\.",
                    "org.apache.syncope.common.report.");
            jdbcTemplate.update("UPDATE ReportletConfInstance SET serializedInstance=? WHERE id=?",
                    new Object[] {updated, row.get("id")});
        }
    }
View Full Code Here

Examples of org.springframework.jdbc.core.JdbcTemplate

    /**
     * {@inheritDoc}
     */
    public String getUserPassword(Long userId) {
        JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
        Table table = AnnotationUtils.findAnnotation(User.class, Table.class);
        return jdbcTemplate.queryForObject(
                "select password from " + table.name() + " where id=?", String.class, userId);
    }
View Full Code Here

Examples of org.springframework.jdbc.core.JdbcTemplate

    private String insertTokenSql = "insert into password_reset_token (username, token, expiration_time) values (?, ?, ?)";
    private String selectTokenSql = "select count(token) from password_reset_token where username=? and token=? and expiration_time > NOW()";

    @Autowired
    public void setDataSource(DataSource dataSource) {
        jdbcTemplate = new JdbcTemplate(dataSource);
    }
View Full Code Here

Examples of org.springframework.jdbc.core.JdbcTemplate

    private String query = null;

    public DatabaseHealthIndicator(DataSource dataSource) {
        this.dataSource = dataSource;
        this.jdbcTemplate = new JdbcTemplate(dataSource);
    }
View Full Code Here

Examples of org.springframework.jdbc.core.JdbcTemplate

        ds.setDriverClassName("com.mysql.jdbc.Driver");
        ds.setUrl("jdbc:mysql://localhost:3306/shiro");
        ds.setUsername("root");
        ds.setPassword("");

        return new JdbcTemplate(ds);
    }
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.