Java:Calculer le temps d’exécution d’une requête

Author:

 int,string,char,static, url, socket, url, socket, java
Download

import java.sql.*;
import javax.swing.*;
 
public class TempsExecutionSQL
{
 
   public static void main(String argv[])
    {
 
                  String myDB="";
        try
        {
          myDB="jdbc:derby://localhost:1527/Avocats";
          Class.forName("org.apache.derby.jdbc.ClientDriver");
          Properties pro=new Properties();
          pro.put("charSet", "utf-8");
          pro.put("username","dd");
          pro.put("password","ddd");
          long debut=System.currentTimeMillis();
          Connection avocatoo_conn=DriverManager.getConnection(myDB,pro);
          ResultSet rs=avocatoo_conn.createStatement()
                  .executeQuery("Select ID, Fonction,\"Nom Complet\",Téléphone"
              + ",GSM,Email,adresse,ville from Contacts");
          while(rs.next())
          {
             String ID=rs.getString(1);
             String fonc=rs.getString(2);
             String nom=rs.getString(3);
             String tel=rs.getString(4);
             String gsm=rs.getString(5);
             String email=rs.getString(6);
             String adresse=rs.getString(7);
             String ville=rs.getString(8);
          }
          long fin=System.currentTimeMillis();
          long diff=fin-debut;
          JOptionPane.showMessageDialog(mainPanel, "Opération terminée en: "+(diff/100f)+"sec");
        }
        catch(Exception err)
            {
                err.printStackTrace();
            }
 
    }
 
}

Cet article Java:Calculer le temps d’exécution d’une requête est apparu en premier sur .