001    /**
002     * Copyright 2010-2013 The Kuali Foundation
003     *
004     * Licensed under the Educational Community License, Version 2.0 (the "License");
005     * you may not use this file except in compliance with the License.
006     * You may obtain a copy of the License at
007     *
008     * http://www.opensource.org/licenses/ecl2.php
009     *
010     * Unless required by applicable law or agreed to in writing, software
011     * distributed under the License is distributed on an "AS IS" BASIS,
012     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013     * See the License for the specific language governing permissions and
014     * limitations under the License.
015     */
016    package org.kuali.common.jdbc;
017    
018    import javax.sql.DataSource;
019    
020    import org.kuali.common.jdbc.context.DatabaseProcessContext;
021    import org.kuali.common.util.LoggerUtils;
022    import org.kuali.common.util.execute.Executable;
023    import org.slf4j.Logger;
024    import org.slf4j.LoggerFactory;
025    import org.springframework.util.Assert;
026    
027    /**
028     * @deprecated
029     */
030    @Deprecated
031    public class ShowConfigExecutable implements Executable {
032    
033            private static final Logger logger = LoggerFactory.getLogger(ShowConfigExecutable.class);
034    
035            DatabaseProcessContext context;
036            DataSource dataSource;
037            JdbcService service;
038            boolean skip;
039    
040            @Override
041            public void execute() {
042                    if (skip) {
043                            logger.info("Skipping execution");
044                            return;
045                    }
046    
047                    Assert.notNull(service, "service is null");
048                    Assert.notNull(context, "context is null");
049                    Assert.notNull(dataSource, "dataSource is null");
050    
051                    logger.info("------------------------------------------------------------------------");
052                    logger.info("JDBC Configuration");
053                    logger.info("------------------------------------------------------------------------");
054                    logger.info("Vendor - {}", context.getVendor());
055                    logger.info("URL - {}", context.getUrl());
056                    logger.info("Schema - {}", context.getSchema());
057                    logger.info("User - {}", LoggerUtils.getUsername(context.getUsername()));
058                    logger.info("Password - {}", LoggerUtils.getPassword(context.getUsername(), context.getPassword()));
059                    logger.info("Driver - {}", context.getDriver());
060                    logger.info("SQL Encoding - {}", context.getEncoding());
061                    // Establish a connection to the db to extract more detailed info
062                    JdbcMetaData metadata = service.getJdbcMetaData(dataSource);
063                    logger.info("Product Name - {}", metadata.getDatabaseProductName());
064                    logger.info("Product Version - {}", metadata.getDatabaseProductVersion());
065                    logger.info("Driver Name - {}", metadata.getDriverName());
066                    logger.info("Driver Version - {}", metadata.getDriverVersion());
067                    logger.info("------------------------------------------------------------------------");
068            }
069    
070            public DatabaseProcessContext getContext() {
071                    return context;
072            }
073    
074            public void setContext(DatabaseProcessContext context) {
075                    this.context = context;
076            }
077    
078            public DataSource getDataSource() {
079                    return dataSource;
080            }
081    
082            public void setDataSource(DataSource dataSource) {
083                    this.dataSource = dataSource;
084            }
085    
086            public JdbcService getService() {
087                    return service;
088            }
089    
090            public void setService(JdbcService service) {
091                    this.service = service;
092            }
093    
094            public boolean isSkip() {
095                    return skip;
096            }
097    
098            public void setSkip(boolean skip) {
099                    this.skip = skip;
100            }
101    
102    }