Advertisement
Guest User

code

a guest
Jan 27th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. public static Scanner scan = new Scanner(System.in);
  2. public static DecimalFormat DecimalFormat = new DecimalFormat("#.##");
  3.  
  4. private static final String USERNAME = "rocoblanatot";
  5. private static final String PASSWORD = "Rogojan19881988";
  6. private static final String CONN_STRING = "jdbc:mysql://localhost:3306/newscheme";
  7.  
  8. public static int Index = 0;
  9.  
  10.  
  11. public static Connection connect;
  12. public ResultSet result;
  13. public static void main(String args[]) throws Exception {
  14.  
  15. Class.forName("com.mysql.jdbc.Driver");
  16. connect = DriverManager.getConnection(CONN_STRING, USERNAME, PASSWORD);
  17. System.out.println("Connected");
  18. get();
  19.  
  20.  
  21.  
  22.  
  23.  
  24. }
  25. public static ArrayList<String> get() throws Exception{
  26. try {
  27.  
  28. PreparedStatement statement = connect.prepareStatement("SELECT YY,DD from book");
  29. ResultSet result = statement.executeQuery("SELECT * from book");
  30.  
  31. ArrayList<String> array = new ArrayList<String>();
  32. ArrayList<Integer> score1 = new ArrayList<Integer>();
  33. ArrayList<Integer> score2 = new ArrayList<Integer>();
  34.  
  35. while(result.next()) {
  36. //System.out.print(result.getString("YY")+"."+result.getString("MM")+"."+result.getString("DD")+
  37. // " "+result.getString("Team1")+" "+result.getString("Team2") );
  38. //System.out.println((" "));
  39.  
  40. array.add(result.getString("YY")+"."+result.getString("MM")+"."+result.getString("DD")+
  41. " "+result.getString("Team1")+" "+result.getString("Team2"));
  42.  
  43. score1.add(result.getInt("Final Team1"));
  44. score2.add(result.getInt("Final Team2"));
  45.  
  46. }
  47. for (String list: array) {
  48. if(list.contains("Manchester")) {
  49. Index = array.indexOf(list);
  50. System.out.println(list + " " + score1.get(Index) +"-"+ score2.get(Index) );
  51.  
  52.  
  53.  
  54. }
  55.  
  56.  
  57.  
  58.  
  59.  
  60. }
  61. return array;
  62. }catch(Exception e) {System.out.println(e);}
  63. return null;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement