gui-playground: move mysql logic into its own module
[se-panther.git] / gui-playground / src / panther / db / MySQLManager.java
blob4f2e6569cf2d43a7597f990a1c5d5b97e74a6829
1 package panther.db;
3 import java.util.ArrayList;
4 import java.sql.*;
6 public class MySQLManager
8 private static final String DB_SCHEMA = "team3";
9 private static final String DB_URL = "jdbc:mysql://robocomp.dyndns.org/" + DB_SCHEMA;
10 private static final String DB_USER = "team3";
11 private static final String DB_PASS = "team3";
13 private static Connection conn;
15 static {
16 conn = null;
18 try {
19 conn = DriverManager.getConnection(DB_URL, DB_USER, DB_PASS);
20 System.out.println("Database connected");
22 catch (SQLException se) {
23 se.printStackTrace();
27 public MySQLManager()
31 public static ArrayList<Student> get_students()
33 ArrayList<Student> students = null;
35 try {
36 students = new ArrayList<Student>();
38 Statement st = conn.createStatement();
39 st.executeQuery("select * from student order by LName;");
41 ResultSet rs = st.getResultSet();
43 while (rs.next()) {
44 students.add(new Student(rs));
47 catch (SQLException se) {
48 students = null;
49 se.printStackTrace();
52 return students;
55 public static RepetoireList get_student_repetoire(int sid)
57 RepetoireList rlist = null;
59 try {
60 Statement st = conn.createStatement();
61 st.executeQuery("select * from repetoire where Student_idStudent=" +
62 sid + ";");
64 ResultSet rs = st.getResultSet();
66 rlist = new RepetoireList(rs);
68 catch (SQLException se) {
69 se.printStackTrace();
72 return rlist;