Package org.springframework.jdbc.core

Examples of org.springframework.jdbc.core.ConnectionCallback


        HashMap keys = new HashMap(1);
        keys.put(getGeneratedKeyNames()[0], key);
        keyHolder.getKeyList().add(keys);
      }
      else {
        jdbcTemplate.execute(new ConnectionCallback() {
          public Object doInConnection(Connection con) throws SQLException, DataAccessException {
            // Do the insert
            PreparedStatement ps = null;
            try {
              ps = con.prepareStatement(getInsertString());
View Full Code Here


                return new MapMaker().makeComputingMap(new Function<DbMediaSource, DbDialect>() {

                    public DbDialect apply(final DbMediaSource source) {
                        DataSource dataSource = dataSourceService.getDataSource(pipelineId, source);
                        final JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
                        return (DbDialect) jdbcTemplate.execute(new ConnectionCallback() {

                            public Object doInConnection(Connection c) throws SQLException, DataAccessException {
                                DatabaseMetaData meta = c.getMetaData();
                                String databaseName = meta.getDatabaseProductName();
                                int databaseMajorVersion = meta.getDatabaseMajorVersion();
View Full Code Here

        this.transactionTemplate = new TransactionTemplate();
        transactionTemplate.setTransactionManager(new DataSourceTransactionManager(jdbcTemplate.getDataSource()));
        transactionTemplate.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW);

        // 初始化一些数据
        jdbcTemplate.execute(new ConnectionCallback() {

            public Object doInConnection(Connection c) throws SQLException, DataAccessException {
                DatabaseMetaData meta = c.getMetaData();
                databaseName = meta.getDatabaseProductName();
                databaseMajorVersion = meta.getDatabaseMajorVersion();
View Full Code Here

        return findTable(jdbcTemplate, catalogName, schemaName, tableName, null);
    }

    public static Table findTable(final JdbcTemplate jdbcTemplate, final String catalogName, final String schemaName,
                                  final String tableName, final DdlUtilsFilter filter) throws Exception {
        return (Table) jdbcTemplate.execute(new ConnectionCallback() {

            public Object doInConnection(Connection con) throws SQLException, DataAccessException {
                Table table = null;
                DatabaseMetaDataWrapper metaData = new DatabaseMetaDataWrapper();
View Full Code Here

    @SuppressWarnings("unchecked")
    public static List<Table> findTables(final JdbcTemplate jdbcTemplate, final String catalogName,
                                         final String schemaName, final String tableNamePattern,
                                         final DdlUtilsFilter filter, final DdlTableNameFilter tableNameFilter)
                                                                                                               throws Exception {
        return (List<Table>) jdbcTemplate.execute(new ConnectionCallback() {

            public Object doInConnection(Connection con) throws SQLException, DataAccessException {
                List<Table> tables = new ArrayList<Table>();
                DatabaseMetaDataWrapper metaData = new DatabaseMetaDataWrapper();
View Full Code Here

        assertEquals(expected, actual);
    }

    @Test
    public void rollback() throws Exception {
        template.execute(new ConnectionCallback() {

            public Object doInConnection(Connection con) throws SQLException, DataAccessException {
                con.setAutoCommit(false);
                con.createStatement().execute("INSERT INTO test (a, b, c) VALUES (4, 5, 6)");
                con.rollback();
View Full Code Here

TOP

Related Classes of org.springframework.jdbc.core.ConnectionCallback

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.