Buscar

cadatramento aluno

Esta é uma pré-visualização de arquivo. Entre para ver o arquivo original

EscolaGeraldoVeloso/build.xml
 
 Builds, tests, and runs the project EscolaGeraldoVeloso.
 
 
EscolaGeraldoVeloso/manifest.mf
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
EscolaGeraldoVeloso/nbproject/build-impl.xml
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Must set src.dir
 Must set test.src.dir
 Must set build.dir
 Must set dist.dir
 Must set build.classes.dir
 Must set dist.javadoc.dir
 Must set build.test.classes.dir
 Must set build.test.results.dir
 Must set build.classes.excludes
 Must set dist.jar
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Must set javac.includes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 No tests executed.
Must set JVM to use for profiling in profiler.info.jvm
 Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Must select some files in the IDE or set javac.includes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 To run this application from the command line without Ant, try:
 
 java -jar "${dist.jar.resolved}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Must select one file in the IDE or set run.class
 
 
 
 Must select one file in the IDE or set run.class
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Must select one file in the IDE or set debug.class
 
 
 
 
 Must select one file in the IDE or set debug.class
 
 
 
 
 Must set fix.includes
 
 
 
 
 
 
 
 
 
 This target only works when run from inside the NetBeans IDE.
 
 
 
 
 
 
 
 
 Must select one file in the IDE or set profile.class
 This target only works when run from inside the NetBeans IDE.
 
 
 
 
 
 
 
 
 This target only works when run from inside the NetBeans IDE.
 
 
 
 
 
 
 
 
 
 
 
 
 This target only works when run from inside the NetBeans IDE.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Must select one file in the IDE or set run.class
 
 
 
 
 
 Must select some files in the IDE or set test.includes
 
 
 
 
 Must select one file in the IDE or set run.class
 
 
 
 
 Must select one file in the IDE or set applet.url
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Must select some files in the IDE or set javac.includes
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 Some tests failed; see details above.
 
 
 
 
 
 
 
 
 Must select some files in the IDE or set test.includes
 
 
 
 Some tests failed; see details above.
 
 
 
 Must select some files in the IDE or set test.class
 Must select some method in the IDE or set test.method
 
 
 
 Some tests failed; see details above.
 
 
 
 
 Must select one file in the IDE or set test.class
 
 
 
 Must select one
file in the IDE or set test.class
 Must select some method in the IDE or set test.method
 
 
 
 
 
 
 
 
 
 
 
 
 
 Must select one file in the IDE or set applet.url
 
 
 
 
 
 
 
 
 Must select one file in the IDE or set applet.url
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
EscolaGeraldoVeloso/nbproject/genfiles.properties
build.xml.data.CRC32=02d8348f
build.xml.script.CRC32=dd22f659
build.xml.stylesheet.CRC32=8064a381@1.75.2.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=02d8348f
nbproject/build-impl.xml.script.CRC32=7e4e5e47
nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48
EscolaGeraldoVeloso/nbproject/project.properties
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=-Aeclipselink.canonicalmodel.use_static_factory=false
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
 ${run.classpath}
debug.test.classpath=\
 ${run.test.classpath}
# Os arquivos em build.classes.dir que devem ser exclu\u00eddos do jar de distribui\u00e7\u00e3o
dist.archive.excludes=
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/EscolaGeraldoVeloso.jar
dist.javadoc.dir=${dist.dir}/javadoc
excludes=
includes=**
jar.compress=false
javac.classpath=\
 ${libs.MySQLDriver.classpath}:\
 ${libs.eclipselink.classpath}:\
 ${libs.beans-binding.classpath}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.processorpath=\
 ${javac.classpath}
javac.source=1.7
javac.target=1.7
javac.test.classpath=\
 ${javac.classpath}:\
 ${build.classes.dir}
javac.test.processorpath=\
 ${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
main.class=Visao.Principal
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
 ${javac.classpath}:\
 ${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.test.classpath=\
 ${javac.test.classpath}:\
 ${build.test.classes.dir}
source.encoding=UTF-8
src.dir=src
test.src.dir=test
EscolaGeraldoVeloso/nbproject/project.xml
 
 org.netbeans.modules.java.j2seproject
 
 
 EscolaGeraldoVeloso
 
 
 
 
 
 
 
 
EscolaGeraldoVeloso/src/Controle/ControleAluno.java
package Controle;
import Modelo.modeloAluno;
import java.sql.ResultSet;
import java.sql.SQLException;
import util.Conexao;
import java.util.ArrayList;
public class ControleAluno {
 public Conexao conexaoBanco;
 
 public ControleAluno() {
 conexaoBanco = new Conexao();
 } 
 public ArrayList selecionaAlunos(String ordem) {
 String consulta = "";
 if(ordem != null){
 consulta = "SELECT * FROM aluno ORDER BY "+ordem;
 }
 else{
 consulta = "SELECT * FROM aluno";
 }
 ArrayList<modeloAluno> listaAluno = new ArrayList<>();
 modeloAluno aluno = new modeloAluno();
 conexaoBanco.abrirConexao();
 try{
 ResultSet rs = conexaoBanco.select.executeQuery(consulta);
 while(rs.next()){
 aluno = new modeloAluno();
 aluno.setMatricula(rs.getInt("aluno_matricula"));
 aluno.setNome(rs.getString("aluno_nome"));
 aluno.setRua(rs.getString("aluno_rua"));
 aluno.setBairro(rs.getString("aluno_bairro"));
 aluno.setCidade(rs.getString("aluno_cidade"));
 aluno.setTelefone(rs.getString("aluno_telefone"));
 aluno.setPeriodo(rs.getString("aluno_periodo"));
 aluno.setCurso(rs.getString("aluno_curso"));
 aluno.setNascimento(rs.getString("aluno_nascimento"));
 
 listaAluno.add(aluno);
 
 }
 conexaoBanco.fecharConexao();
 }
 catch(SQLException e){
 System.out.println("Erro na sentenca"+e.getMessage());
 }
 
 return listaAluno;
 }
 
 
 
 public void editarAluno(modeloAluno aluno) throws SQLException{
 
 String Sql = "UPDATE aluno SET aluno_nome = ?, "
 + " aluno_rua = ?,"
 + " aluno_bairro = ?,"
 + " aluno_cidade = ?,"
 + " aluno_telefone = ?,"
 + " aluno_periodo = ?,"
 + " aluno_curso = ?,"
 + " aluno_nascimento = ?"
 + " WHERE aluno_matricula = ?;";
 
 conexaoBanco.abrirConexao();
 try{
 conexaoBanco.sentenca = conexaoBanco.conexao.prepareStatement(Sql);
 conexaoBanco.sentenca.setString(1, aluno.getNome());
 conexaoBanco.sentenca.setString(2, aluno.getRua());
 conexaoBanco.sentenca.setString(3, aluno.getBairro());
 conexaoBanco.sentenca.setString(4, aluno.getCidade());
 conexaoBanco.sentenca.setString(5, aluno.getTelefone());
 conexaoBanco.sentenca.setString(6, aluno.getPeriodo());
 conexaoBanco.sentenca.setString(7, aluno.getCurso());
 conexaoBanco.sentenca.setString(8, aluno.getNascimento());
 conexaoBanco.sentenca.setInt(9, aluno.getMatricula());
 conexaoBanco.sentenca.executeUpdate();
 }
 catch(SQLException e){
 System.out.println("Erro ao alterar: "+e.getMessage());
 }
 //conexaoBanco.fecharConexao();
 
 }
 
 public int codigoMaxAluno(){
 conexaoBanco.abrirConexao();
 String select = "SELECT MAX(aluno_matricula) CODIGO FROM aluno";
 int codigo = 0;
 try{
 ResultSet rs = conexaoBanco.select.executeQuery(select);
while(rs.next()){
 codigo = rs.getInt("CODIGO");
 }
 conexaoBanco.fecharConexao();
 }
 catch(SQLException e){
 System.out.println("Erro na sentenca"+e.getMessage());
 }
 return codigo; 
 }
 
 public modeloAluno pesquisaAlunoId(modeloAluno aluno){
 conexaoBanco.abrirConexao();
 String select = "SELECT * FROM aluno WHERE aluno_matricula = " + aluno.getMatricula();
 try{
 ResultSet rs = conexaoBanco.select.executeQuery(select);
 while(rs.next()){
 aluno = new modeloAluno();
 aluno.setMatricula(rs.getInt("aluno_matricula"));
 aluno.setNome(rs.getString("aluno_nome"));
 aluno.setRua(rs.getString("aluno_rua"));
 aluno.setBairro(rs.getString("aluno_bairro"));
 aluno.setCidade(rs.getString("aluno_cidade"));
 aluno.setTelefone(rs.getString("aluno_telefone"));
 aluno.setPeriodo(rs.getString("aluno_periodo"));
 aluno.setCurso(rs.getString("aluno_curso"));
 aluno.setNascimento(rs.getString("aluno_nascimento"));
 
 
 }
 // conexaoBanco.fecharConexao();
 }
 catch(SQLException e){
 System.out.println("Erro na sentenca"+e.getMessage());
 }
 
 return aluno;
 } 
 
 public void inserir(modeloAluno aluno){
 String Sql = "INSERT INTO aluno (aluno_nome,aluno_rua,aluno_bairro,aluno_cidade,aluno_telefone,aluno_periodo,aluno_curso,aluno_nascimento ) "
 + "VALUES (?,?,?,?,?,?,?,?)";
 
 conexaoBanco.abrirConexao();
 try{
 conexaoBanco.sentenca = conexaoBanco.conexao.prepareStatement(Sql);
 conexaoBanco.sentenca.setString(1, aluno.getNome());
 conexaoBanco.sentenca.setString(2, aluno.getRua());
 conexaoBanco.sentenca.setString(3, aluno.getBairro());
 conexaoBanco.sentenca.setString(4, aluno.getCidade());
 conexaoBanco.sentenca.setString(5, aluno.getTelefone());
 conexaoBanco.sentenca.setString(6, aluno.getPeriodo());
 conexaoBanco.sentenca.setString(7, aluno.getCurso());
 conexaoBanco.sentenca.setString(8, aluno.getNascimento());
 conexaoBanco.sentenca.execute();
 
 
 
 }
 catch(SQLException e){
 System.out.println("Erro ao inserir: "+e.getMessage());
 }
 conexaoBanco.fecharConexao();
 }
}
EscolaGeraldoVeloso/src/Controle/ControleDisciplina.java
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Controle;
import Modelo.modeloDisciplina;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import util.Conexao;
/**
 *
 * @author Marco Tulio
 */
public class ControleDisciplina {
 
 public Conexao conexaoBanco;
 public ControleDisciplina() {
 conexaoBanco = new Conexao();
 }
 
 public int codigoMaxDisciplina(){
 conexaoBanco.abrirConexao();
 String select = "SELECT MAX(disciplina_id) CODIGO FROM disciplina";
 int codigo = 0;
 try{
 ResultSet rs = conexaoBanco.select.executeQuery(select);
 while(rs.next()){
 codigo = rs.getInt("CODIGO");
 }
 conexaoBanco.fecharConexao();
 }
 catch(SQLException e){
 System.out.println("Erro na sentenca"+e.getMessage());
 }
 return codigo; 
 }
 
 
 public ArrayList selecionaDisciplinas(String ordem) {
 String consulta = "";
 if(ordem != null){
 consulta = "SELECT * FROM disciplina ORDER BY "+ordem;
 }
 else{
 consulta = "SELECT * FROM disciplina";
 }
 ArrayList<modeloDisciplina> listaDisiciplina = new ArrayList<>();
 modeloDisciplina disciplina = new modeloDisciplina();
 conexaoBanco.abrirConexao();
 try{
 ResultSet rs = conexaoBanco.select.executeQuery(consulta);
 while(rs.next()){
 disciplina = new modeloDisciplina();
 disciplina.setId(rs.getInt("disciplina_id"));
 disciplina.setNome(rs.getString("disciplina_nome"));
 disciplina.setProfessor(rs.getString("disciplina_professor"));
 listaDisiciplina.add(disciplina);
 
 
 
 }
 conexaoBanco.fecharConexao();
 }
 catch(SQLException e){
 System.out.println("Erro na sentenca"+e.getMessage());
 }
 
 return listaDisiciplina;
 }
 
 
 
 public void inserir(modeloDisciplina disciplina){
 String Sql = "INSERT INTO disciplina (disciplina_nome,disciplina_professor) "
 + "VALUES (?,?)";
 
 conexaoBanco.abrirConexao();
 try{
 conexaoBanco.sentenca = conexaoBanco.conexao.prepareStatement(Sql);
 conexaoBanco.sentenca.setString(1, disciplina.getNome());
 conexaoBanco.sentenca.setString(2, disciplina.getProfessor());
 conexaoBanco.sentenca.execute();
 }
 catch(SQLException e){
 System.out.println("Erro ao inserir: "+e.getMessage());
 }
 conexaoBanco.fecharConexao();
 }
 
 
 public modeloDisciplina buscarDisciplina(int codigo) {
 String select = "SELECT disciplina_id, disciplina_nome,disciplina_professor "
 + "FROM disciplina "
 + "WHERE disciplina_id = "+codigo;
 
 modeloDisciplina disciplina = new modeloDisciplina();
 
 conexaoBanco.abrirConexao();
 try{
 ResultSet rs = conexaoBanco.select.executeQuery(select);
 while(rs.next()){
 disciplina = new modeloDisciplina();
 disciplina.setId(rs.getInt("disciplina_id"));
 disciplina.setNome(rs.getString("disciplina_nome"));
 disciplina.setProfessor(rs.getString("disciplina_professor"));
 
 }
 conexaoBanco.fecharConexao();
 
 }
 catch(SQLException e){
 System.out.println("Erro na sentenca: "+e.getMessage());
 }
 
 return disciplina;
 }
 
 
 public modeloDisciplina pesquisaDisciplinaId(modeloDisciplina disciplina){
 conexaoBanco.abrirConexao();
 String select = "SELECT * FROM disciplina WHERE disciplina_id = " + disciplina.getId();
 try{
 ResultSet rs = conexaoBanco.select.executeQuery(select);
 while(rs.next()){
 disciplina = new modeloDisciplina();
 disciplina.setId(rs.getInt("disciplina_id"));
 disciplina.setNome(rs.getString("disciplina_nome"));
 disciplina.setProfessor(rs.getString("disciplina_professor"));
 
 }
 // conexaoBanco.fecharConexao();
 }
 catch(SQLException e){
 System.out.println("Erro na sentenca"+e.getMessage());
 }
 
 return disciplina;
 } 
 
 
 
 public void removeDisciplina(modeloDisciplina disciplina) {
 // deletarItemVenda(venda);
 
 String sql = "DELETE FROM DISCIPLINA "
 + "WHERE disciplina_id = ?;";
 conexaoBanco.abrirConexao();
 
 try{
 conexaoBanco.sentenca = conexaoBanco.conexao.prepareStatement(sql);
 conexaoBanco.sentenca.setInt(1,
disciplina.getId());
 conexaoBanco.sentenca.execute();
 }
 catch(SQLException e){
 System.out.println("Erro ao excluir: "+e.getMessage());
 }
 conexaoBanco.fecharConexao();
 }
 
 public void editarDisciplina(modeloDisciplina disciplina) throws SQLException{
 
 String Sql = "UPDATE disciplina SET disciplina_nome = ?, "
 + " disciplina_professor = ? "
 + " WHERE disciplina_id = ?;";
 
 conexaoBanco.abrirConexao();
 try{
 conexaoBanco.sentenca = conexaoBanco.conexao.prepareStatement(Sql);
 conexaoBanco.sentenca.setString(1, disciplina.getNome());
 conexaoBanco.sentenca.setString(2, disciplina.getProfessor());
 conexaoBanco.sentenca.setInt(3,disciplina.getId());
 conexaoBanco.sentenca.executeUpdate();
 }
 catch(SQLException e){
 System.out.println("Erro ao alterar: "+e.getMessage());
 }
 //conexaoBanco.fecharConexao();
 
 }
}
EscolaGeraldoVeloso/src/Controle/ControleMatricula.java
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Controle;
import Modelo.modeloDisciplina;
import Modelo.modeloMatricula;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import util.Conexao;
/**
 *
 * @author Marco Tulio
 */
public class ControleMatricula {
 
 
 public Conexao conexaoBanco;
 public ControleMatricula() {
 conexaoBanco = new Conexao();
 }
 
 public int codigoMaxMatricula(){
 conexaoBanco.abrirConexao();
 String select = "SELECT MAX(matricula_id) CODIGO FROM matricula";
 int codigo = 0;
 try{
 ResultSet rs = conexaoBanco.select.executeQuery(select);
 while(rs.next()){
 codigo = rs.getInt("CODIGO");
 }
 conexaoBanco.fecharConexao();
 }
 catch(SQLException e){
 System.out.println("Erro na sentenca"+e.getMessage());
 }
 return codigo; 
 }
 
 public void removeMatricula(modeloMatricula matricula) {
 String sql = "DELETE FROM matricula "
 + "WHERE matricula_id = ? ;";
 conexaoBanco.abrirConexao();
 
 try{
 conexaoBanco.sentenca = conexaoBanco.conexao.prepareStatement(sql);
 conexaoBanco.sentenca.setInt(1, matricula.getMatricula_id());
 conexaoBanco.sentenca.execute();
 }
 catch(SQLException e){
 System.out.println("Erro ao excluir: "+e.getMessage());
 }
 conexaoBanco.fecharConexao();
 }
 
 
 public modeloDisciplina pesquisaDisciplinaId(modeloDisciplina disciplina){
 conexaoBanco.abrirConexao();
 String select = "SELECT * FROM disciplina WHERE disciplina_id = " + disciplina.getId();
 try{
 ResultSet rs = conexaoBanco.select.executeQuery(select);
 while(rs.next()){
 disciplina = new modeloDisciplina();
 disciplina.setNome(rs.getString("disciplina_nome"));
 disciplina.setProfessor(rs.getString("disciplina_professor"));
 
 }
 // conexaoBanco.fecharConexao();
 }
 catch(SQLException e){
 System.out.println("Erro na sentenca"+e.getMessage());
 }
 
 return disciplina;
 } 
 
 public modeloMatricula buscarMatricula(int codigo) {
 String select = "SELECT matricula_id, matricula_aluno_id, matricula_aluno_nome,matricula_aluno_periodo,matricula_aluno_curso,matricula_disciplina_id,matricula_disciplina_nome,matricula_disciplina_professor "
 + "FROM matricula "
 + "WHERE matricula_id = "+codigo ;
 
 modeloMatricula matriculaRetorno = new modeloMatricula();
 
 conexaoBanco.abrirConexao();
 try{
 ResultSet rs = conexaoBanco.select.executeQuery(select);
 while(rs.next()){
 // matriculaRetorno = new modeloMatricula();
 
 matriculaRetorno.setMatricula_id(rs.getInt("matricula_id"));
 
 matriculaRetorno.setAluno_id(rs.getInt("matricula_aluno_id"));
 matriculaRetorno.setAluno_nome(rs.getString("matricula_aluno_nome"));
 matriculaRetorno.setAluno_periodo(rs.getString("matricula_aluno_periodo"));
 matriculaRetorno.setAluno_curso(rs.getString("matricula_aluno_curso"));
 
 matriculaRetorno.setDisciplina_id(rs.getInt("matricula_disciplina_id"));
 matriculaRetorno.setDisciplina_nome(rs.getString("matricula_disciplina_nome"));
 matriculaRetorno.setDisciplina_professor(rs.getString("matricula_disciplina_professor"));
 
 return matriculaRetorno;
 
 }
 conexaoBanco.fecharConexao();
 
 }
 catch(SQLException e){
 System.out.println("Erro na sentenca: "+e.getMessage());
 }
 return matriculaRetorno;
 } 
 
 public ArrayList selecionaMatricula(String ordem) {
 String consulta = "";
 if(ordem != null){
 consulta = "SELECT * FROM matricula ORDER BY "+ordem;
 }
 else{
 consulta = "SELECT * FROM matricula";
 }
 ArrayList<modeloMatricula> listaMatricula = new ArrayList<>();
 modeloMatricula matricula = new modeloMatricula();
 conexaoBanco.abrirConexao();
 try{
 ResultSet rs = conexaoBanco.select.executeQuery(consulta);
 while(rs.next()){
 matricula = new modeloMatricula();
 matricula.setMatricula_id(rs.getInt("matricula_id"));
 
 matricula.setAluno_id(rs.getInt("matricula_aluno_id"));
 matricula.setAluno_nome(rs.getString("matricula_aluno_nome"));
 matricula.setAluno_periodo(rs.getString("matricula_aluno_periodo"));
 matricula.setAluno_curso(rs.getString("matricula_aluno_curso"));
 
 matricula.setDisciplina_id(rs.getInt("matricula_disciplina_id"));
 matricula.setDisciplina_nome(rs.getString("matricula_disciplina_nome"));
 matricula.setDisciplina_professor(rs.getString("matricula_disciplina_professor"));
 listaMatricula.add(matricula);
 }
 conexaoBanco.fecharConexao();
 }
 catch(SQLException e){
 System.out.println("Erro na sentenca"+e.getMessage());
 }
 
 return listaMatricula;
 }
 
 public void editarMatricula(modeloMatricula matricula) throws SQLException{
 
 String Sql = "UPDATE matricula SET matricula_aluno_nome = ?, "
 + " matricula_aluno_id = ?,"
 + " matricula_aluno_periodo = ? ,"
 + " matricula_aluno_curso = ? ,"
 + " matricula_disciplina_id = ? ,"
 + " matricula_disciplina_nome = ? ,"
 + " matricula_disciplina_professor = ? "
 + " WHERE matricula_id = ? ;";
 
 conexaoBanco.abrirConexao();
 try{
 conexaoBanco.sentenca = conexaoBanco.conexao.prepareStatement(Sql);
 
 conexaoBanco.sentenca.setString(1, matricula.getAluno_nome());
 conexaoBanco.sentenca.setInt(2, matricula.getAluno_id());
 conexaoBanco.sentenca.setString(3, matricula.getAluno_periodo());
conexaoBanco.sentenca.setString(4, matricula.getAluno_curso());
 conexaoBanco.sentenca.setInt(5, matricula.getDisciplina_id());
 conexaoBanco.sentenca.setString(6, matricula.getDisciplina_nome());
 conexaoBanco.sentenca.setString(7, matricula.getDisciplina_professor());
 conexaoBanco.sentenca.setInt(8, matricula.getMatricula_id());
 conexaoBanco.sentenca.executeUpdate();
 }
 catch(SQLException e){
 System.out.println("Erro ao alterar: "+e.getMessage());
 }
 //conexaoBanco.fecharConexao();
 
 }
 
 
 
 public void inserirMatricula(modeloMatricula matricula){
 String Sql = "INSERT INTO matricula (matricula_aluno_id, matricula_aluno_nome, matricula_aluno_periodo, matricula_aluno_curso,matricula_disciplina_id, matricula_disciplina_nome, matricula_disciplina_professor)"
 + "VALUES(?,?,?,?,?,?,?)";
 
 conexaoBanco.abrirConexao();
 try{
 
 conexaoBanco.sentenca = conexaoBanco.conexao.prepareStatement(Sql);
 conexaoBanco.sentenca.setInt(1, matricula.getAluno_id());
 conexaoBanco.sentenca.setString(2, matricula.getAluno_nome());
 conexaoBanco.sentenca.setString(3, matricula.getAluno_periodo());
 conexaoBanco.sentenca.setString(4, matricula.getAluno_curso());
 conexaoBanco.sentenca.setInt(5, matricula.getDisciplina_id());
 conexaoBanco.sentenca.setString(6, matricula.getDisciplina_nome());
 conexaoBanco.sentenca.setString(7, matricula.getDisciplina_professor());
 
 conexaoBanco.sentenca.execute();
 }
 catch(SQLException e){
 System.out.println("Erro ao inserir: "+e.getMessage());
 }
 conexaoBanco.fecharConexao();
 }
 
}
EscolaGeraldoVeloso/src/Modelo/modeloAluno.java
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Modelo;
import java.util.ArrayList;
/**
 *
 * @author modeloAluno
 */
public class modeloAluno {
 public int matricula;
 public String nome;
 public String rua;
 public String bairro;
 public String cidade;
 public String telefone;
 public String periodo;
 public String curso;
 public String nascimento;
 private ArrayList<modeloAluno> listaAlunos;
 public modeloAluno() {
 matricula = 0;
 nome = "";
 rua = "";
 bairro = "";
 cidade = "";
 telefone = "";
 periodo = "";
 curso = "";
 nascimento = "";
 listaAlunos = new ArrayList<modeloAluno>();
 
 }
 public modeloAluno(int matricula, String nome, String rua, String bairro, String cidade, String telefone, String periodo, String curso, String nascimento, ArrayList<modeloAluno> listaAlunos) {
 this.matricula = matricula;
 this.nome = nome;
 this.rua = rua;
 this.bairro = bairro;
 this.cidade = cidade;
 this.telefone = telefone;
 this.periodo = periodo;
 this.curso = curso;
 this.nascimento = nascimento;
 this.listaAlunos = listaAlunos;
 }
 public int getMatricula() {
 return matricula;
 }
 public void setMatricula(int matricula) {
 this.matricula = matricula;
 }
 public String getNome() {
 return nome;
 }
 public void setNome(String nome) {
 this.nome = nome;
 }
 public String getRua() {
 return rua;
 }
 public void setRua(String rua) {
 this.rua = rua;
 }
 public String getBairro() {
 return bairro;
 }
 public void setBairro(String bairro) {
 this.bairro = bairro;
 }
 public String getCidade() {
 return cidade;
 }
 public void setCidade(String cidade) {
 this.cidade = cidade;
 }
 public String getTelefone() {
 return telefone;
 }
 public void setTelefone(String telefone) {
 this.telefone = telefone;
 }
 public String getPeriodo() {
 return periodo;
 }
 public void setPeriodo(String periodo) {
 this.periodo = periodo;
 }
 public String getCurso() {
 return curso;
 }
 public void setCurso(String curso) {
 this.curso = curso;
 }
 public String getNascimento() {
 return nascimento;
 }
 public void setNascimento(String nascimento) {
 this.nascimento = nascimento;
 }
 public ArrayList<modeloAluno> getListaAlunos() {
 return listaAlunos;
 }
 public void setListaAlunos(ArrayList<modeloAluno> listaAlunos) {
 this.listaAlunos = listaAlunos;
 }
 
 
}
EscolaGeraldoVeloso/src/Modelo/modeloDisciplina.java
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Modelo;
import java.util.ArrayList;
/**
 *
 * @author Marco Tulio
 */
public class modeloDisciplina {
 
 private Integer id;
 private String nome;
 private String professor;
 private ArrayList<modeloDisciplina> listaDisciplinas;
 public modeloDisciplina() {
 id = 0;
 nome = "";
 professor = "";
 // listaDisciplinas = new ArrayList<modeloDisciplina>();
 }
 public modeloDisciplina(int id, String nome, String professor) {
 this.id = id;
 this.nome = nome;
 this.professor = professor;
 // this.listaDisciplinas = listaDisciplinas;
 }
 public int getId() {
 return id;
 }
 public void setId(Integer id) {
 this.id = id;
 }
 public String getNome() {
 return nome;
 }
 public void setNome(String nome) {
 this.nome = nome;
 }
 public String getProfessor() {
 return professor;
 }
 public void setProfessor(String professor) {
 this.professor = professor;
 }
/*
 public ArrayList<modeloDisciplina> getListaDisciplinas() {
 return listaDisciplinas;
 }
 public void setListaDisciplinas(ArrayList<modeloDisciplina> listaDisciplinas) {
 this.listaDisciplinas = listaDisciplinas;
 }
 */ 
 
 
}
EscolaGeraldoVeloso/src/Modelo/modeloMatricula.java
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package Modelo;
import java.util.ArrayList;
/**
 *
 * @author Marco Tulio
 */
public class modeloMatricula {
 private int matricula_id ;
 public Integer Aluno_id ;
 public String Aluno_nome;
 private String Aluno_periodo;
 private String Aluno_curso;
 
 private Integer disciplina_id;
 private String disciplina_nome;
 private String disciplina_professor;
 
 private ArrayList<modeloMatricula> listaMatricula;
 public modeloMatricula() {
 Aluno_id = 0;
 Aluno_nome = "";
 Aluno_periodo = "";
 Aluno_curso = "";
 disciplina_id = 0;
 disciplina_nome = "";
 disciplina_professor = "";
 matricula_id = 0;
 listaMatricula = new ArrayList<modeloMatricula>();
 }
 public modeloMatricula(Integer Aluno_id, String Aluno_nome, String Aluno_periodo, String Aluno_curso, Integer disciplina_id, String disciplina_nome, String disciplina_professor, Integer matricula_id, ArrayList<modeloMatricula> listaMatricula) {
 this.Aluno_id = Aluno_id;
 this.Aluno_nome = Aluno_nome;
 this.Aluno_periodo = Aluno_periodo;
 this.Aluno_curso = Aluno_curso;
this.disciplina_id = disciplina_id;
 this.disciplina_nome = disciplina_nome;
 this.disciplina_professor = disciplina_professor;
 // this.matricula_id = matricula_id;
 this.listaMatricula = listaMatricula;
 }
 public Integer getAluno_id() {
 return Aluno_id;
 }
 public void setAluno_id(Integer Aluno_id) {
 this.Aluno_id = Aluno_id;
 }
 public String getAluno_nome() {
 return Aluno_nome;
 }
 public void setAluno_nome(String Aluno_nome) {
 this.Aluno_nome = Aluno_nome;
 }
 public String getAluno_periodo() {
 return Aluno_periodo;
 }
 public void setAluno_periodo(String Aluno_periodo) {
 this.Aluno_periodo = Aluno_periodo;
 }
 public String getAluno_curso() {
 return Aluno_curso;
 }
 public void setAluno_curso(String Aluno_curso) {
 this.Aluno_curso = Aluno_curso;
 }
 public Integer getDisciplina_id() {
 return disciplina_id;
 }
 public void setDisciplina_id(Integer disciplina_id) {
 this.disciplina_id = disciplina_id;
 }
 public String getDisciplina_nome() {
 return disciplina_nome;
 }
 public void setDisciplina_nome(String disciplina_nome) {
 this.disciplina_nome = disciplina_nome;
 }
 public String getDisciplina_professor() {
 return disciplina_professor;
 }
 public void setDisciplina_professor(String disciplina_professor) {
 this.disciplina_professor = disciplina_professor;
 }
 public Integer getMatricula_id() {
 return matricula_id;
 }
 public void setMatricula_id(Integer matricula_id) {
 this.matricula_id = matricula_id;
 }
 public ArrayList<modeloMatricula> getListaMatricula() {
 return listaMatricula;
 }
 public void setListaMatricula(ArrayList<modeloMatricula> listaMatricula) {
 this.listaMatricula = listaMatricula;
 }
 
}
EscolaGeraldoVeloso/src/TableModel/AlunoTableModel.java
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package TableModel;
import Modelo.modeloAluno;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
/**
 *
 * @author Marco Tulio
 */
public class AlunoTableModel extends AbstractTableModel{
 private ArrayList<modeloAluno> linhas;
 private String[] colunas = new String[] {"aluno_matricula", "aluno_nome", "aluno_rua", "aluno_bairro", "aluno_cidade","aluno_telefone","aluno_periodo","aluno_curso","aluno_nascimento"};
 private static final int aluno_matricula = 0;
 private static final int aluno_nome = 1;
 private static final int aluno_rua = 2;
 private static final int aluno_bairro = 3;
 private static final int aluno_cidade = 4;
 private static final int aluno_telefone = 5;
 private static final int aluno_periodo =6;
 private static final int aluno_curso = 7;
 private static final int aluno_nascimento = 8;
 
 public AlunoTableModel() {
 linhas = new ArrayList<modeloAluno>();
 }
 public AlunoTableModel(ArrayList<modeloAluno> listaDeAluno) {
 linhas = new ArrayList<modeloAluno>(listaDeAluno);
 }
 @Override
 public int getRowCount() {
 return linhas.size();
 }
 @Override
 public int getColumnCount() {
 return colunas.length;
 }
 
 public String getColumnName(int columnIndex) {
 return colunas[columnIndex];
 }
 
 public Class<?> getColumnClass(int columnIndex) {
 switch (columnIndex) {
 case aluno_matricula:
 return String.class;
 case aluno_nome:
 return String.class;
 case aluno_rua:
 return String.class;
 case aluno_bairro:
 return String.class;
 case aluno_cidade:
 return String.class;
 case aluno_telefone:
 return String.class;
 case aluno_periodo:
 return String.class;
 case aluno_curso:
 return String.class;
 case aluno_nascimento:
 return String.class;
 default:
 // Não deve ocorrer, pois só existem 2 colunas
 throw new IndexOutOfBoundsException("columnIndex out of bounds");
 }
 }
 
 @Override
 public boolean isCellEditable(int rowIndex, int columnIndex) {
 if(columnIndex == 2){
 return true;
 }
 return false;
 }
 @Override
 public Object getValueAt(int rowIndex, int columnIndex) {
 modeloAluno aluno = linhas.get(rowIndex);
 
 switch(columnIndex) {
 case aluno_matricula:
 return aluno.getMatricula();
 case aluno_nome:
 return aluno.getNome();
 case aluno_rua:
 return aluno.getRua();
 case aluno_bairro:
 return aluno.getBairro();
 case aluno_cidade:
 return aluno.getCidade();
 case aluno_telefone:
 return aluno.getTelefone();
 case aluno_periodo:
 return aluno.getPeriodo();
 case aluno_curso:
 return aluno.getCurso();
 case aluno_nascimento:
 return aluno.getNascimento();
 default:
 // Não deve ocorrer, pois só existem 2 colunas
 throw new IndexOutOfBoundsException("columnIndex out of bounds");
 }
 }
 
 @Override
 public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
 modeloAluno aluno = linhas.get(rowIndex);
 switch(columnIndex) {
 case aluno_matricula:
 aluno.setMatricula(Integer.parseInt((String) aValue));
 
 // producao.setCodigo(Integer.parseInt((String) aValue));
 
 case aluno_nome:
 aluno.setNome((String) aValue);
 
 // producao.getProduto().setNome((String) aValue);
 
 case aluno_rua:
 aluno.setRua((String) aValue);
 
 // producao.setQuantidade(Integer.parseInt((String) aValue));
 case aluno_bairro:
 aluno.setBairro((String) aValue);
 // produto.setValorUnit(Double.parseDouble((String) aValue)); 
 case aluno_cidade:
 aluno.setCidade((String) aValue);
 // producao.getProduto().setNome((String) aValue);
 case aluno_telefone:
 aluno.setTelefone((String) aValue);
 //producao.getProduto().setNome((String) aValue);
 case aluno_periodo:
 aluno.setPeriodo((String) aValue);
 // producao.getProduto().setNome((String) aValue);
 case aluno_curso:
 aluno.setCurso((String) aValue);
 // producao.getProduto().setNome((String) aValue);
 case aluno_nascimento:
 aluno.setNascimento((String) aValue);
 // producao.getProduto().setNome((String) aValue);
 
 
 
 
 default:
 // Não deve ocorrer, pois só existem 2 colunas
 throw new IndexOutOfBoundsException("columnIndex out of bounds");
 }
 }
 
 // Retorna o Produto referente a linha especificada
 public modeloAluno getAlunoLista(int indiceLinha) {
 return linhas.get(indiceLinha);
 }
 
 public ArrayList getAlunoLista() {
 return linhas;
 }
 
 public void addAluno(modeloAluno aluno){
 linhas.add(aluno);
/*
 Pega a quantidade de registros e subtrai 1 para
 achar o último índice. A subtração é necessária
 porque os índices começam em zero;
 */
 int ultimoIndice = getRowCount() - 1;
 
 // Notifica a mudança.
 fireTableRowsInserted(ultimoIndice, ultimoIndice);
 }
 
 public void updateAlunos(modeloAluno aluno, int linha){
 linhas.get(linha).setMatricula(aluno.getMatricula());
 linhas.get(linha).setNome(aluno.getNome());
 linhas.get(linha).setRua(aluno.getRua());
 linhas.get(linha).setBairro(aluno.getBairro());
 linhas.get(linha).setCidade(aluno.getCidade());
 linhas.get(linha).setTelefone(aluno.getTelefone());
 linhas.get(linha).setPeriodo(aluno.getPeriodo());
 linhas.get(linha).setCurso(aluno.getCurso());
 linhas.get(linha).setNascimento(aluno.getNascimento());
 
 /*
 Pega a quantidade de registros e subtrai 1 para
 achar o último índice. A subtração é necessária
 porque os índices começam em zero;
 */
 int ultimoIndice = getRowCount() - 1;
 
 // Notifica a mudança.
 fireTableRowsInserted(ultimoIndice, ultimoIndice);
 }
 
 public void removeAlunos(int indiceLinha) {
 linhas.remove(indiceLinha);
 
 // Notifica a mudança.
 fireTableRowsDeleted(indiceLinha, indiceLinha);
 }
 
 public void addListDeAlunos(ArrayList<modeloAluno>listaAluno) {
 int indice = getRowCount();
 
 linhas.addAll(listaAluno);
 
 // Notifica a mudança.
 fireTableRowsInserted(indice, indice + listaAluno.size());
 }
 
 public void limpar() {
 linhas.clear();
 
 // Notifica a mudança.
 fireTableDataChanged();
 }
}
EscolaGeraldoVeloso/src/TableModel/DisciplinaTableModel.java
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package TableModel;
import Modelo.modeloDisciplina;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
/**
 *
 * @author Marco Tulio
 */
public class DisciplinaTableModel extends AbstractTableModel{
 private ArrayList<modeloDisciplina> linhas;
 private String[] colunas = new String[] {"disciplina_id", "disciplina_nome", "disciplina_professor"};
 private static final int disciplina_id = 0;
 private static final int disciplina_nome = 1;
 private static final int disciplina_professor = 2;
 
 public DisciplinaTableModel() {
 linhas = new ArrayList<modeloDisciplina>();
 }
 public DisciplinaTableModel(ArrayList<modeloDisciplina> listaDeDisciplina) {
 linhas = new ArrayList<modeloDisciplina>(listaDeDisciplina);
 }
 @Override
 public int getRowCount() {
 return linhas.size();
 }
 @Override
 public int getColumnCount() {
 return colunas.length;
 }
 
 public String getColumnName(int columnIndex) {
 return colunas[columnIndex];
 }
 
 public Class<?> getColumnClass(int columnIndex) {
 switch (columnIndex) {
 case disciplina_id:
 return String.class;
 case disciplina_nome:
 return String.class;
 case disciplina_professor:
 return String.class;
 default:
 // Não deve ocorrer, pois só existem 2 colunas
 throw new IndexOutOfBoundsException("columnIndex out of bounds");
 }
 }
 
 @Override
 public boolean isCellEditable(int rowIndex, int columnIndex) {
 if(columnIndex == 2){
 return true;
 }
 return false;
 }
 @Override
 public Object getValueAt(int rowIndex, int columnIndex) {
 modeloDisciplina disciplina = linhas.get(rowIndex);
 
 switch(columnIndex) {
 case disciplina_id:
 return disciplina.getId();
 case disciplina_nome:
 return disciplina.getNome();
 case disciplina_professor:
 return disciplina.getProfessor();
 default:
 // Não deve ocorrer, pois só existem 2 colunas
 throw new IndexOutOfBoundsException("columnIndex out of bounds");
 }
 }
 
 @Override
 public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
 modeloDisciplina disciplina = linhas.get(rowIndex);
 switch(columnIndex) {
 case disciplina_id:
 disciplina.setId((int) aValue);
 
 // producao.setCodigo(Integer.parseInt((String) aValue));
 
 case disciplina_nome:
 disciplina.setNome((String) aValue);
 
 // producao.getProduto().setNome((String) aValue);
 
 case disciplina_professor:
 disciplina.setProfessor((String) aValue);
 
 default:
 // Não deve ocorrer, pois só existem 2 colunas
 throw new IndexOutOfBoundsException("columnIndex out of bounds");
 }
 }
 
 // Retorna o Produto referente a linha especificada
 public modeloDisciplina getDisciplinaLista(int indiceLinha) {
 return linhas.get(indiceLinha);
 }
 
 public ArrayList getDisciplinaLista() {
 return linhas;
 }
 
 public void addDisciplina(modeloDisciplina disciplina){
 linhas.add(disciplina);
 
 /*
 Pega a quantidade de registros e subtrai 1 para
 achar o último índice. A subtração é necessária
 porque os índices começam em zero;
 */
 int ultimoIndice = getRowCount() - 1;
 
 // Notifica a mudança.
 fireTableRowsInserted(ultimoIndice, ultimoIndice);
 }
 
 public void updateDisciplinas(modeloDisciplina disciplina, int linha){
 linhas.get(linha).setId(disciplina.getId());
 linhas.get(linha).setNome(disciplina.getNome());
 linhas.get(linha).setProfessor(disciplina.getProfessor());
 
 /*
 Pega a quantidade de registros e subtrai 1 para
 achar o último índice. A subtração é necessária
 porque os índices começam em zero;
 */
 int ultimoIndice = getRowCount() - 1;
 
 // Notifica a mudança.
 fireTableRowsInserted(ultimoIndice, ultimoIndice);
 }
 
 public void removeDisciplinas(int indiceLinha) {
 linhas.remove(indiceLinha);
 
 // Notifica a mudança.
 fireTableRowsDeleted(indiceLinha, indiceLinha);
 }
 
 public void addListDeDiciplinas(ArrayList<modeloDisciplina>listaDisciplina) {
 int indice = getRowCount();
 
 linhas.addAll(listaDisciplina);
 
 // Notifica a mudança.
 fireTableRowsInserted(indice, indice + listaDisciplina.size());
 }
 
 public void limpar() {
 linhas.clear();
 
 // Notifica a mudança.
 fireTableDataChanged();
 }
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
EscolaGeraldoVeloso/src/TableModel/MatriculaTableModel.java
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package TableModel;
import Modelo.modeloDisciplina;
import Modelo.modeloMatricula;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
/**
 *
 * @author Marco Tulio
 */
public class MatriculaTableModel
extends AbstractTableModel{
 private ArrayList<modeloMatricula> linhas;
 private String[] colunas = new String[] {"matricula_id","matricula_aluno_id","matricula_aluno_nome","matricula_aluno_curso","matricula_aluno_periodo","matricula_disciplina_id","matricula_disciplina_nome", "matricula_disciplina_professor"};
 private static final int matricula_id = 0;
 private static final int matricula_aluno_id = 1; 
 private static final int matricula_aluno_nome = 2;
 private static final int matricula_aluno_curso = 3;
 private static final int matricula_aluno_periodo = 4;
 private static final int matricula_disciplina_id = 5;
 private static final int matricula_disciplina_nome = 6;
 private static final int matricula_disciplina_professor = 7;
 
 public MatriculaTableModel() {
 linhas = new ArrayList<modeloMatricula>();
 }
 public MatriculaTableModel(ArrayList<modeloMatricula> listaDeMatricula) {
 linhas = new ArrayList<modeloMatricula>(listaDeMatricula);
 }
 @Override
 public int getRowCount() {
 return linhas.size();
 }
 @Override
 public int getColumnCount() {
 return colunas.length;
 }
 
 public String getColumnName(int columnIndex) {
 return colunas[columnIndex];
 }
 
 public Class<?> getColumnClass(int columnIndex) {
 switch (columnIndex) {
 case matricula_id:
 return String.class;
 case matricula_aluno_id:
 return String.class;
 case matricula_aluno_nome:
 return String.class;
 case matricula_aluno_periodo:
 return String.class;
 case matricula_aluno_curso:
 return String.class;
 case matricula_disciplina_id:
 return String.class;
 case matricula_disciplina_nome:
 return String.class;
 case matricula_disciplina_professor:
 return String.class;
 default:
 // Não deve ocorrer, pois só existem 2 colunas
 throw new IndexOutOfBoundsException("columnIndex out of bounds");
 }
 }
 
 @Override
 public boolean isCellEditable(int rowIndex, int columnIndex) {
 if(columnIndex == 2){
 return true;
 }
 return false;
 }
 @Override
 public Object getValueAt(int rowIndex, int columnIndex) {
 modeloMatricula matricula = linhas.get(rowIndex);
 
 switch(columnIndex) {
 
 case matricula_id:
 return matricula.getMatricula_id();
 
 case matricula_aluno_id:
 return matricula.getAluno_id();
 
 case matricula_aluno_nome:
 return matricula.getAluno_nome();
 
 case matricula_aluno_periodo:
 return matricula.getAluno_periodo();
 
 case matricula_aluno_curso:
 return matricula.getAluno_curso();
 
 case matricula_disciplina_id:
 return matricula.getDisciplina_id();
 
 case matricula_disciplina_nome:
 return matricula.getDisciplina_nome();
 
 case matricula_disciplina_professor:
 return matricula.getDisciplina_professor();
 
 default:
 // Não deve ocorrer, pois só existem 2 colunas
 throw new IndexOutOfBoundsException("columnIndex out of bounds");
 }
 }
 
 @Override
 public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
 modeloMatricula matricula = linhas.get(rowIndex);
 switch(columnIndex) {
 case matricula_id:
 matricula.setMatricula_id((int) aValue);
 
 case matricula_aluno_id:
 matricula.setAluno_id((int) aValue);
 case matricula_aluno_nome:
 matricula.setAluno_nome((String) aValue);
 case matricula_aluno_periodo:
 matricula.setAluno_periodo((String) aValue);
 case matricula_aluno_curso:
 matricula.setAluno_curso((String) aValue);
 case matricula_disciplina_id:
 matricula.setDisciplina_id((int) aValue);
 case matricula_disciplina_nome:
 matricula.setDisciplina_nome((String) aValue);
 case matricula_disciplina_professor:
 matricula.setDisciplina_professor((String) aValue);
 
 default:
 // Não deve ocorrer, pois só existem 2 colunas
 throw new IndexOutOfBoundsException("columnIndex out of bounds");
 }
 }
 
 // Retorna o Produto referente a linha especificada
 public modeloMatricula getMatriculaLista(int indiceLinha) {
 return linhas.get(indiceLinha);
 }
 
 public ArrayList getDisciplinaLista() {
 return linhas;
 }
 
 public void addMatricula(modeloMatricula matricula){
 linhas.add(matricula);
 
 /*
 Pega a quantidade de registros e subtrai 1 para
 achar o último índice. A subtração é necessária
 porque os índices começam em zero;
 */
 int ultimoIndice = getRowCount() - 1;
 
 // Notifica a mudança.
 fireTableRowsInserted(ultimoIndice, ultimoIndice);
 }
 
 public void updateDisciplinas(modeloMatricula matricula, int linha){
 linhas.get(linha).setMatricula_id(matricula.getMatricula_id());
 
 linhas.get(linha).setAluno_id(matricula.getAluno_id());
 linhas.get(linha).setAluno_nome(matricula.getAluno_nome());
 linhas.get(linha).setAluno_periodo(matricula.getAluno_periodo());
 linhas.get(linha).setAluno_curso(matricula.getAluno_curso());
 
 linhas.get(linha).setDisciplina_id(matricula.getDisciplina_id());
 linhas.get(linha).setDisciplina_nome(matricula.getDisciplina_nome());
 linhas.get(linha).setDisciplina_professor(matricula.getDisciplina_professor());
 
 /*
 Pega a quantidade de registros e subtrai 1 para
 achar o último índice. A subtração é necessária
 porque os índices começam em zero;
 */
 int ultimoIndice = getRowCount() - 1;
 
 // Notifica a mudança.
 fireTableRowsInserted(ultimoIndice, ultimoIndice);
 }
 
 public void removeMatriculas(int indiceLinha) {
 linhas.remove(indiceLinha);
 
 // Notifica a mudança.
 fireTableRowsDeleted(indiceLinha, indiceLinha);
 }
 
 public void addListDeMatriculas(ArrayList<modeloMatricula>listaMatricula) {
 int indice = getRowCount();
 
 linhas.addAll(listaMatricula);
 
 // Notifica a mudança.
 fireTableRowsInserted(indice, indice + listaMatricula.size());
 }
 
 public void limpar() {
 linhas.clear();
 
 // Notifica a mudança.
 fireTableDataChanged();
 }
 
}
EscolaGeraldoVeloso/src/util/Conexao.java
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package util;
import java.sql.*;
/**
 *
 * @author Aluno
 */
public class Conexao {
 public Connection conexao; //Fazer a conexao no banco
 public Statement select; //Executar as Sequencia SQL
 public PreparedStatement sentenca;
 
 public void abrirConexao() {
 try{
 Class.forName("com.mysql.jdbc.Driver");
 String url = "jdbc:mysql://localhost/projeto";
 String usuario = "root";
 String senha = "root";
conexao = DriverManager.getConnection(url, usuario, senha);
 select = conexao.createStatement();
 
 
 }
 catch(SQLException e){
 System.out.println("Erro no banco"+e.getMessage());
 }
 catch(ClassNotFoundException e){
 System.out.println("Erro no driver: "+e.getMessage());
 }
 }
 
 public void fecharConexao() {
 try{ 
 select.close();
 conexao.close(); 
 }
 catch(SQLException e){
 System.out.println("Erro no banco: "+e.getMessage());
 }
 
 }
}
EscolaGeraldoVeloso/src/Visao/Principal.form
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
EscolaGeraldoVeloso/src/Visao/Principal.java
package Visao;
/**
 *
 * @author Marco Tulio
 */
public class Principal extends javax.swing.JFrame {
 public Principal() {
 initComponents();
 
 }
 @SuppressWarnings("unchecked")
 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
 private void initComponents() {
 jPanelPrincipal = new javax.swing.JPanel();
 jMenuBar1 = new javax.swing.JMenuBar();
 jMenu1 = new javax.swing.JMenu();
 jmiAluno = new javax.swing.JMenuItem();
 jmiDisciplina = new javax.swing.JMenuItem();
 jmiMatricula = new javax.swing.JMenuItem();
 setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
 setTitle("Escola Estadual Geraldo Veloso");
 setExtendedState(6);
 setState(6);
 javax.swing.GroupLayout jPanelPrincipalLayout = new javax.swing.GroupLayout(jPanelPrincipal);
 jPanelPrincipal.setLayout(jPanelPrincipalLayout);
 jPanelPrincipalLayout.setHorizontalGroup(
 jPanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 .addGap(0, 1053, Short.MAX_VALUE)
 );
 jPanelPrincipalLayout.setVerticalGroup(
 jPanelPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 .addGap(0, 504, Short.MAX_VALUE)
 );
 jMenu1.setText("Arquivo");
 jmiAluno.setText("Aluno");
 jmiAluno.addActionListener(new java.awt.event.ActionListener() {
 public void actionPerformed(java.awt.event.ActionEvent evt) {
 jmiAlunoActionPerformed(evt);
 }
 });
 jMenu1.add(jmiAluno);
 jmiDisciplina.setText("Disciplina");
 jmiDisciplina.addActionListener(new java.awt.event.ActionListener() {
 public void actionPerformed(java.awt.event.ActionEvent evt) {
 jmiDisciplinaActionPerformed(evt);
 }
 });
 jMenu1.add(jmiDisciplina);
 jmiMatricula.setText("Matricula");
 jmiMatricula.addActionListener(new java.awt.event.ActionListener() {
 public void actionPerformed(java.awt.event.ActionEvent evt) {
 jmiMatriculaActionPerformed(evt);
 }
 });
 jMenu1.add(jmiMatricula);
 jMenuBar1.add(jMenu1);
 setJMenuBar(jMenuBar1);
 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
 getContentPane().setLayout(layout);
 layout.setHorizontalGroup(
 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 .addComponent(jPanelPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 );
 layout.setVerticalGroup(
 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
 .addComponent(jPanelPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
 );
 pack();
 }// </editor-fold>//GEN-END:initComponents
 
 private void jmiAlunoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiAlunoActionPerformed
 Tela_Aluno aluno = new Tela_Aluno();
 aluno.setVisible(true);
 jPanelPrincipal.add(aluno);
// TODO add your handling code here:
 }//GEN-LAST:event_jmiAlunoActionPerformed
 private void jmiMatriculaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiMatriculaActionPerformed
Tela_matricula matricula = new Tela_matricula();
matricula.setVisible(true);
jPanelPrincipal.add(matricula);
// TODO add your handling code here:
 }//GEN-LAST:event_jmiMatriculaActionPerformed
 private void jmiDisciplinaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jmiDisciplinaActionPerformed
 Tela_Disciplina disciplina = new Tela_Disciplina();
 disciplina.setVisible(true);
 jPanelPrincipal.add(disciplina);
 
// TODO add your handling code here:
 }//GEN-LAST:event_jmiDisciplinaActionPerformed
 /**
 * @param args the command line arguments
 */
 public static void main(String args[]) {
 /* Set the Nimbus look and feel */
 //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
 /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
 * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
 */
 try {
 for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
 if ("Nimbus".equals(info.getName())) {
 javax.swing.UIManager.setLookAndFeel(info.getClassName());
 break;
 }
 }
 } catch (ClassNotFoundException ex) {
 java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
 } catch (InstantiationException ex) {
 java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
 } catch (IllegalAccessException ex) {
 java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
 } catch (javax.swing.UnsupportedLookAndFeelException ex) {
 java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
 }
 //</editor-fold>
 /* Create and display the form */
 java.awt.EventQueue.invokeLater(new Runnable() {
 @Override
 public void run() {
 new Principal().setVisible(true);
 }
 });
 }
 // Variables declaration - do not modify//GEN-BEGIN:variables
 private javax.swing.JMenu jMenu1;
 private javax.swing.JMenuBar jMenuBar1;
 public javax.swing.JPanel jPanelPrincipal;
 public javax.swing.JMenuItem jmiAluno;
 private javax.swing.JMenuItem jmiDisciplina;

Teste o Premium para desbloquear

Aproveite todos os benefícios por 3 dias sem pagar! 😉
Já tem cadastro?

Outros materiais