Skip to content
Permalink
Browse files Browse the repository at this point in the history
Prooteçao contra SQL Injection
  • Loading branch information
jovit committed Mar 12, 2015
1 parent e370500 commit 34eed1f
Show file tree
Hide file tree
Showing 45 changed files with 1,038 additions and 5,340 deletions.
22 changes: 22 additions & 0 deletions Escola Eclipse/.metadata/.log
Expand Up @@ -883,3 +883,25 @@ user global configuration and to define the default location to store repositori
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
!SESSION 2015-03-12 08:36:40.726 -----------------------------------------------
eclipse.buildId=4.4.2.M20150204-1700
java.version=1.8.0_25
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=pt_BR
Framework arguments: -product org.eclipse.epp.package.jee.product
Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

!ENTRY org.eclipse.egit.ui 2 0 2015-03-12 08:37:09.397
!MESSAGE Warning: EGit couldn't detect the installation path "gitPrefix" of native Git. Hence EGit can't respect system level
Git settings which might be configured in ${gitPrefix}/etc/gitconfig under the native Git installation directory.
The most important of these settings is core.autocrlf. Git for Windows by default sets this parameter to true in
this system level configuration. The Git installation location can be configured on the
Team > Git > Configuration preference page's 'System Settings' tab.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.

!ENTRY org.eclipse.egit.ui 2 0 2015-03-12 08:37:09.407
!MESSAGE Warning: The environment variable HOME is not set. The following directory will be used to store the Git
user global configuration and to define the default location to store repositories: 'Z:\'. If this is
not correct please set the HOME environment variable and restart Eclipse. Otherwise Git for Windows and
EGit might behave differently since they see different configuration options.
This warning can be switched off on the Team > Git > Confirmations and Warnings preference page.
@@ -0,0 +1,152 @@
package banco_de_dados.dao;

import java.sql.ResultSet;
import java.util.ArrayList;

import banco_de_dados.BD;
import banco_de_dados.ConnectionData;
import banco_de_dados.dbo.Responsavel;

public class Responsaveis {
private BD bancoConec;

public Responsaveis()throws Exception{
this.bancoConec = new BD(ConnectionData.DRIVER,
ConnectionData.CONNECTION_STRING,
ConnectionData.USER, ConnectionData.PASSWORD);
}

public void inserirResponsavel(Responsavel responsavel) throws Exception{
ResultSet result = this.bancoConec.execConsulta("Select * from ACI_Responsavel where Email='"
+responsavel.getEmail()+"'");
if(result.first()){
throw new Exception("Responsavel com esse email j� existente");
}

result.close();

String comSQL = "insert into ACI_Responsavel values('"+
responsavel.getEmail()+"','"+responsavel.getNome()+
"','"+ responsavel.getTelefone()+"','"+responsavel.getEndereco() + "')";

this.bancoConec.execComando(comSQL);
}

public void removerResponsavel(String emailResponsavel) throws Exception{
ResultSet result = this.bancoConec.execConsulta("Select * from ACI_Responsavel where Email='"
+emailResponsavel.replace("'", "")+"'");

if(!result.first()){
result.close();
throw new Exception("Respons�vel com esse Email inexistente");
}
result.close();

String comSql = "select * from ACI_Aluno where Responsavel='" + emailResponsavel + "'";
result = this.bancoConec.execConsulta(comSql);

if(result.first()){
result.close();
throw new Exception("Esse Respons�vel Possui Alunos Cadastrados, Delete Os Alunos Primeiro");
}

result.close();

comSql = "delete from ACI_Responsavel where Email='"+emailResponsavel + "'";
this.bancoConec.execComando(comSql);
}

public void editarResponsavel(Responsavel responsavel) throws Exception{
ResultSet result = this.bancoConec.execConsulta("Select * from ACI_Responsavel where Email='"
+responsavel.getEmail()+"'");
if(!result.first()){
throw new Exception("Responsavel com esse email j� inexistente");
}

result.close();

String comSql = "update ACI_Responsavel set Nome='"+responsavel.getNome()+
"', Telefone='" + responsavel.getTelefone() + "', Endereco='" + responsavel.getEndereco()
+ "' where Email='"+ responsavel.getEmail() + "'";
this.bancoConec.execComando(comSql);
}

public ResultSet getResponsaveis() throws Exception{
ResultSet result = this.bancoConec.execConsulta("Select * from ACI_Responsavel");
if(result.first()){
result.beforeFirst();
return result;
}else{
return null;
}
}

public Responsavel getResponsavel(String email) throws Exception{
ResultSet result = this.bancoConec.execConsulta("Select * from ACI_Responsavel where Email='"+email.replace("'", "");+"'");
if(result.first()){
Responsavel responsavel = new Responsavel(result.getString("Email"), result.getString("Nome"),result.getString("Telefone")
,result.getString("Endereco"));
return responsavel;
}else{
return null;
}
}

public ArrayList<Responsavel> buscarResponsavel(String email, String nome, String telefone, String endereco) throws Exception{

if ((email == null) && (nome == null) && (telefone == null) && (endereco == null))
throw new Exception("Preencha pelo menos um dos campos para realizar a busca");

String cmd = "";

cmd += "select * from ACI_Responsavel where ";

if (email != null) {
cmd += "email like '%"+email.replace("'", "")+"%'";
if ((nome != null) || (telefone != null) || (endereco != null))
cmd += " and ";
}

if (nome != null) {
cmd += "nome like '%"+nome.replace("'", "")+"%'";
if ((telefone != null) || (endereco != null))
cmd += " and ";
}

if (telefone != null) {
cmd += "telefone like '%"+telefone.replace("'", "")+"%'";
if (endereco != null)
cmd += " and ";
}

if (endereco != null)
cmd += "endereco like '%"+endereco.replace("'", "")+"%'";

ResultSet result = this.bancoConec.execConsulta(cmd);

if (result.first()) {
String rEmail, rNome, rTelefone, rEndereco;
ArrayList<Responsavel> aResp = new ArrayList<Responsavel>();
rEmail = result.getString("email");
rNome = result.getString("nome");
rTelefone = result.getString("telefone");
rEndereco = result.getString("endereco");
Responsavel r = new Responsavel(rEmail,rNome,rTelefone,rEndereco);
aResp.add(r);

while (result.next()) {
rEmail = result.getString("email");
rNome = result.getString("nome");
rTelefone = result.getString("telefone");
rEndereco = result.getString("endereco");
Responsavel resp = new Responsavel(rEmail,rNome,rTelefone,rEndereco);
aResp.add(resp);
}

return aResp;
} else {
throw new Exception("Nenhum resultado");
}
}

}

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 34eed1f

Please sign in to comment.