Skip to content

Instantly share code, notes, and snippets.

@FernandoCutire
Created May 26, 2021 00:50
Show Gist options
  • Save FernandoCutire/97327f2746f80a31472ba7e7f1a4ccb2 to your computer and use it in GitHub Desktop.
Save FernandoCutire/97327f2746f80a31472ba7e7f1a4ccb2 to your computer and use it in GitHub Desktop.
Ejercicio groovy resuelto Banco general
#!/usr/bin/env groovy
import groovy.sql.Sql
import groovy.util.logging.*
import java.sql.SQLException
import org.apache.log4j.*
import BGUTPConexion
import BGUTPLogger
@Log4j
class Ejercicio3 {
static void main(String[] args) {
Logger log = BGUTPLogger.getLogger(this.getName())
def String i_estudiante = args[0]
println "Estudiante:" + i_estudiante
def Sql sqlSample = Sql.newInstance(BGUTPConexion.getDataSource('dbSample'))
calculaInteres(sqlSample, i_estudiante)
}
static private void calculaInteres(Sql sqlSample, String i_estudiante) {
println "Ejecutando cálculo de interés"
try {
sqlSample.call ( "call sp_calculo_interes_groovy (${i_estudiante},${Sql.INTEGER} )")
{retorno ->
if (retorno != 0){
log.error "calculaInteres SQL: Error Calculando intereses ${i_estudiante}"
}
}
}catch (SQLException sqlex){
while (sqlex != null){
log.error "calculaInteres SQL: ${sqlex.getErrorCode()} ${sqlex.getMessage()}"
sqlex = sqlex.getNextException()
}
System.exit(1)
}catch(Exception ex) {
log.error "calculaInteres: ${ex}"
System.exit(1)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment