package com.rjconsultores;

import java.sql.SQLException;

import javax.sql.DataSource;

import oracle.jdbc.pool.OracleDataSource;

import com.rjconsultores.ventaboletos.FlyWay;



/**
 * Uma classe utilitaria para executar scripts do flyway sem ter q executar a aplicação.
 * 
 * Para configurar o data source do cliente e executar o método main.
 * 
 * @author gleimar
 *
 */
public class TesteFlyway {
	public static void main(String args[]){
		DataSource dataSource = null;
		try{
			dataSource = getOracleDataSource();
			
			FlyWay.getInstance().defineDataSource(dataSource);
			FlyWay.getInstance().start();
			
		}finally{
			if (dataSource != null){
				try {
					((OracleDataSource)dataSource).getConnection().close();
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
		}
		
		
	}
	public static DataSource getOracleDataSource(){
		
		OracleDataSource oracleDS = null;
		try {
			
			oracleDS = new OracleDataSource();
			oracleDS.setURL("jdbc:oracle:thin:@189.3.216.130:1521:ORCL");
			oracleDS.setUser("vtabol");
			oracleDS.setPassword("vtax05");
		
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return oracleDS;
	}
	public static DataSource getOracleDataSourceMottaPRD(){
		
		OracleDataSource oracleDS = null;
		try {
			
			oracleDS = new OracleDataSource();
			oracleDS.setURL("jdbc:oracle:thin:@db-motta-dev.cdc9b6uvj4gk.us-east-1.rds.amazonaws.com:1521:ORCL");
			oracleDS.setUser("vtabol");
			oracleDS.setPassword("vtax05");
		
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return oracleDS;
	}
	public static DataSource getOracleDataSourceRDS_OURO_PRATA(){
		
		OracleDataSource oracleDS = null;
		try {
			
			oracleDS = new OracleDataSource();
			oracleDS.setURL("jdbc:oracle:thin:@gop-tb-bd.ckqxookhjev1.sa-east-1.rds.amazonaws.com:1521:TOTALBUS");
			oracleDS.setUser("vtabol");
			oracleDS.setPassword("vtax05");
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return oracleDS;
	}
	
	public static DataSource getOracleDataSourceCOMPORTE_TESTE(){
		
		OracleDataSource oracleDS = null;
		try {
			
			oracleDS = new OracleDataSource();
			oracleDS.setURL("jdbc:oracle:thin:@db-proj.cg09ytaizn5g.us-east-1.rds.amazonaws.com:1521:ORCL");
			oracleDS.setUser("vtabol");
			oracleDS.setPassword("totalbus");
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return oracleDS;
	}

	public static DataSource getOracleDataSourceRDS_PLANALTO(){
		
		OracleDataSource oracleDS = null;
		try {
			
			oracleDS = new OracleDataSource();
			oracleDS.setURL("jdbc:oracle:thin:@oratbus.ctjqx1i0rbag.us-east-1.rds.amazonaws.com:1521:orcltbus");
			oracleDS.setUser("vtabol");
			oracleDS.setPassword("vtax05");
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return oracleDS;
	}
	public static DataSource getOracleDataSourceRDS_JCA_PROD(){
		
		OracleDataSource oracleDS = null;
		try {
			
			oracleDS = new OracleDataSource();
			oracleDS.setURL("jdbc:oracle:thin:@viacaocometa-db-prod.cyn0nr1ifhsh.us-east-1.rds.amazonaws.com:1521:ORCL");
			oracleDS.setUser("vtabol");
			oracleDS.setPassword("jcax05");
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return oracleDS;
	}
	public static DataSource getOracleDataSourceRDS_SERRA_VERDE(){
		
		OracleDataSource oracleDS = null;
		try {
			
			oracleDS = new OracleDataSource();
			oracleDS.setURL("jdbc:oracle:thin:@db-prj-trem.cg09ytaizn5g.us-east-1.rds.amazonaws.com:1521:ORCL");
			oracleDS.setUser("vtabol");
			oracleDS.setPassword("vtabol");
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return oracleDS;
	}
	
}
