-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathService.jws
executable file
·81 lines (64 loc) · 2.57 KB
/
Service.jws
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class Service {
String connectionURL = "jdbc:mysql://localhost:3306/PAP";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
public String insertUser(String PrimeiroNome, String UltimoNome, String Email, String Senha, String Telefone) {
int rset = 0;
String resultado = null;
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "root", "");
statement = connection.createStatement();
rs = statement.executeQuery("SELECT Codigo FROM usuario WHERE Email = '" + Email + "'");
if(rs.next()) {
resultado = "existe";
} else {
rset = statement.executeUpdate("INSERT INTO usuario(PrimeiroNome, UltimoNome, Email, Saldo, Senha, Telefone) VALUES('" + PrimeiroNome +"', '" + UltimoNome + "', '" + Email + "', 0, '" + Senha + "', '" + Telefone + "')");
resultado = "sucesso";
}
connection.close();
} catch (Exception e) {
resultado = e.toString();
}
return resultado;
}
public String[] login(String email, String senha) {
String connectionURL = "jdbc:mysql://localhost:3306/PAP";
Connection connection = null;
Statement statement = null;
ResultSet rs = null;
String resultado[] = new String[6];
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
connection = DriverManager.getConnection(connectionURL, "root", "");
statement = connection.createStatement();
rs = statement.executeQuery("SELECT * FROM usuario WHERE Email = '" + email + "' AND Senha = '" + senha + "'");
while (rs.next()) {
resultado[0] = rs.getString("Codigo");
resultado[1] = rs.getString("PrimeiroNome");
resultado[2] = rs.getString("UltimoNome");
resultado[3] = rs.getString("Email");
resultado[4] = rs.getString("Saldo");
resultado[5] = rs.getString("Senha");
}
connection.close();
} catch (Exception e) {
resultado[0] = e.toString();
}
return resultado;
}
public int delete(int valor1, int valor2) {
return valor1 + valor2;
}
public int edit(int valor1, int valor2) {
return valor1 + valor2;
}
public int list(int valor1, int valor2) {
return valor1 + valor2;
}
}