-
Notifications
You must be signed in to change notification settings - Fork 1
/
SelectWinner.java
40 lines (31 loc) · 1.35 KB
/
SelectWinner.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
import java.util.*;
import java.io.*;
import java.lang.*;
import java.sql.*;
public class SelectWinner
{
public static void winner()
{
Class.forName("com.mysql.jdbc.Driver");
//DON'T FORGET TO PUT THE USERNAME AND PASS FOR YOUR DRIVER CONNECTION TO THE DATABASE BELOW
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/");
Statement instruction = conn.createStatement();
ResultSet result = instruction.executeQuery("SELECT teamname FROM user u");
//NOT SURE HOW TO DO THIS
while(u.teamname)
{
teampnts(u.teamname);
}
}
public static void teampnts(String team)
{
Class.forName("com.mysql.jdbc.Driver");
//DON'T FORGET TO PUT THE USERNAME AND PASS FOR YOUR DRIVER CONNECTION TO THE DATABASE BELOW
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/");
Statement instruction = conn.createStatement();
ResultSet result1 = instruction.executeQuery("SELECT calpoints FROM players p WHERE owner="+team+"");
//HOW DO YOU TAKE VALUE FROM EACH ROW AND ADD TOGETHER?????
//sum of "calpoints" of players owned by "team" = "userpoints"
ResultSet result2 = intruction.executeQuery("UPDATE user u SET weekpoints="+userpoints+"");
}
}