Aniadido informes
This commit is contained in:
38
src/VistaControlador/ModeloInformes.java
Normal file
38
src/VistaControlador/ModeloInformes.java
Normal file
@@ -0,0 +1,38 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user