Advertisement
Guest User

Untitled

a guest
Mar 10th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.25 KB | None | 0 0
  1. public static void main(String[] args) throws SQLException {
  2.  
  3.         Connection con = null;
  4.         PreparedStatement pst = null;
  5.         ResultSet rs = null;
  6.  
  7.  
  8.         String cs = "URL";
  9.         String user = "nina";
  10.         String password = "ninaerkul";
  11.         public double startdato;
  12.         public double sluttdato;
  13.  
  14.  
  15.         try {
  16.  
  17.             con = DriverManager.getConnection(cs, user, password);
  18.  
  19.             String query = "SELECT Count(treningsøktID), Sum(Varighet), Average(prestasjon), Max(personlig form) FROM treningsøkt WHERE startdato =< dato =< sluttdato";
  20.  
  21.             pst = con.prepareStatement(query);
  22.            
  23.  
  24.             do {
  25.                 rs = pst.getResultSet();
  26.  
  27.                
  28.  
  29.                     System.out.print("Dint beste treningsøkt i perioden" + startdato "" + sluttdato "var");
  30.                    
  31.                     System.out.println(rs.getString);
  32.                 }
  33.  
  34.              
  35.  
  36.            
  37.  
  38.         } finally {
  39.  
  40.             if (rs != null) {
  41.                 rs.close();
  42.             }
  43.  
  44.             if (pst != null) {
  45.                 pst.close();
  46.             }
  47.  
  48.             if (con != null) {
  49.                 con.close();
  50.             }
  51.  
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement