-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAluno.java
45 lines (36 loc) · 1.33 KB
/
Aluno.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.sql.*;
public class Aluno extends Pessoa {
protected int Cod_Turma;
public Aluno(String Nome, String CPF, String Data_Nasc, int Matricula, String Telefone, String Email, String Senha, int Cod_Turma, int func) {
super(Nome, CPF, Data_Nasc, Matricula, Telefone, Email, Senha, func);
this.Cod_Turma = Cod_Turma;
Connection connection;
ResultSet rs;
String url = "jdbc:postgresql://localhost:5432/POOproject";
String un = "postgres";
//String pwd = "ifpb";
String pwd = "1111";
try{
Class.forName("org.postgresql.Driver");
connection = DriverManager.getConnection(url,un,pwd);
Statement st = connection.createStatement();
String query = "INSERT INTO ALUNO values ('"+ Nome +"', '"+ CPF +"', '"+ Data_Nasc +"', "+ Matricula +", '"+ Telefone +"', '"+ Email +"', '"+ Senha +"', "+ Cod_Turma+", "+ func +");";
st.executeUpdate(query);
st.close();
connection.close();
}
catch(ClassNotFoundException cnfe){
System.out.println("Nao foi possivel encontrar o Driver apropriado");
}
catch(SQLException sqle){
sqle.printStackTrace();
System.out.println("Nao foi possivel conectar ao SGBD");
}
}
public int getCod_Turma() {
return Cod_Turma;
}
public void setCod_Turma(int cod_Turma) {
Cod_Turma = cod_Turma;
}
}