package VistaControlador;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

public class ModeloInformes {
	Connection controlador;	
	ModeloInformes(){
			String url="jdbc:mariadb://localhost:3306/informes?user=root&password=1234";
	        try {
	                this.controlador=DriverManager.getConnection(url);

	        } catch (SQLException e) {
	                e.printStackTrace();
	        }
	        
		}
	
	Vector<String> anios() {
		Vector<String> ret = new Vector<String>();
		String query = "select distinct year(transacciones.fecha) from transacciones;";
		try {
			PreparedStatement stmt = this.controlador.prepareStatement(query);
			ResultSet resultado = stmt.executeQuery();
			while(resultado.next()) {
				ret.add(resultado.getString(1));
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return ret;
	}
}
