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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
|
package selection_tables;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Test {
public static void main(String[] args) {
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
String url = "jdbc:mysql://localhost:3306/Tpch";
String user = "******";
String password = "******";
try {
con = DriverManager.getConnection(url, user, password);
double start_TE=System.currentTimeMillis();
pst = con.prepareStatement("select * from region where r_name='ASIA' ");
double end_TE=System.currentTimeMillis();
// System.out.println("startQ1 "+startQ1);
// System.out.println("endQ1 "+endQ1);
double diffQ1 = (end_TE-start_TE);
System.out.println("diffQ1 "+diffQ1);
} catch (SQLException ex) {
Logger lgr = Logger.getLogger(Test.class.getName());
lgr.log(Level.SEVERE, ex.getMessage(), ex);
} finally {
try {
if (rs != null) {
rs.close();
}
if (pst != null) {
pst.close();
}
if (con != null) {
con.close();
}
} catch (SQLException ex) {
Logger lgr = Logger.getLogger(Test.class.getName());
lgr.log(Level.WARNING, ex.getMessage(), ex);
}
} } } |
Partager