Skip to content

Commit 841eec0

Browse files
Alterado README e criando pequeno projeto utilizando conceitos aprendidos
1 parent 4b7d6a3 commit 841eec0

File tree

7 files changed

+107
-1
lines changed

7 files changed

+107
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Curso da [TreinaWeb](https://www.treinaweb.com.br/): Java Básico.
2525
- Classes;
2626
- Programação concorrente;
2727
- Trabalhando com arquivos;
28-
- Servidor MySQL;
28+
- Servidor [MySQL](https://www.mysql.com/);
2929
- Banco de dados no Java;
3030
- Introdução ao Swing;
3131
- Trabalhando com eventos.

cadastro-pessoas/.classpath

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.8.0_171"/>
4+
<classpathentry kind="src" path="src"/>
5+
<classpathentry kind="lib" path="libs/mysql-connector-java-8.0.12.jar"/>
6+
<classpathentry kind="output" path="bin"/>
7+
</classpath>

cadastro-pessoas/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/

cadastro-pessoas/.project

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>CadastroPessoas</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
</projectDescription>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
5+
org.eclipse.jdt.core.compiler.compliance=1.8
6+
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
7+
org.eclipse.jdt.core.compiler.debug.localVariable=generate
8+
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
9+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
10+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
11+
org.eclipse.jdt.core.compiler.source=1.8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package br.com.treinaweb.cadastro.model;
2+
3+
public class Pessoa {
4+
5+
private int id;
6+
private String nome;
7+
private int idade;
8+
9+
public Pessoa(int id, String nome, int idade) {
10+
this.id = id;
11+
this.nome = nome;
12+
this.idade = idade;
13+
}
14+
15+
public int getId() {
16+
return id;
17+
}
18+
public void setId(int id) {
19+
this.id = id;
20+
}
21+
22+
public String getNome() {
23+
return nome;
24+
}
25+
public void setNome(String nome) {
26+
this.nome = nome;
27+
}
28+
29+
public int getIdade() {
30+
return idade;
31+
}
32+
public void setIdade(int idade) {
33+
this.idade = idade;
34+
}
35+
36+
@Override
37+
public String toString() {
38+
return "Pessoa [id=" + id + ", nome=" + nome + ", idade=" + idade + "]";
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package br.com.treinaweb.cadastro.utils;
2+
3+
import java.sql.Connection;
4+
import java.sql.DriverManager;
5+
import java.sql.PreparedStatement;
6+
import java.sql.ResultSet;
7+
import java.sql.SQLException;
8+
import java.sql.Statement;
9+
10+
public class DbUtils {
11+
12+
public static Connection getConnection() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
13+
Class.forName("com.mysql.jdbc.Driver").newInstance();
14+
//String de conexão
15+
String url = "jdbc:mysql://127.0.0.1:3306/banco?useTimezone=true&serverTimezone=UTC";
16+
String usuario ="root";
17+
String senha ="valchan";
18+
Connection connection = DriverManager.getConnection(url,usuario,senha);
19+
return connection;
20+
}
21+
//SELECT
22+
public static ResultSet executeSelect(Connection con,String sql) throws SQLException {
23+
Statement query = con.createStatement();
24+
return query.executeQuery(sql);
25+
}
26+
//INSERT, UPDATE, DELETE
27+
public static PreparedStatement criarPreparedStatement(Connection con,String sql) throws SQLException {
28+
return con.prepareStatement(sql);
29+
}
30+
}

0 commit comments

Comments
 (0)