Databases Reference
In-Depth Information
String name = result.getString("first_name")
+ " " + result.getString("last_name");
System.out.println(name);
}
}
ps.close();
} catch (Exception e) {
System.out.println(String.format("Error %s",
e.getLocalizedMessage()));
System.exit(1);
}
}
public static void singleConnection(Connection conn)
throws SQLException {
try {
for (int j = 0; j < iterations; ++j) {
Statement query = conn.createStatement();
ResultSet result = query.executeQuery(
"select first_name, last_name
from employees");
while (result.next()) {
String name = result.getString("first_name")
+ " " + result.getString("last_name");
System.out.println(name);
}
query.close();
}
} catch (Exception e) {
System.out.println(String.format("Error %s",
e.getLocalizedMessage()));
System.exit(1);
}
}
public static void main(String[] args) throws SQLException {
Connection conn = null;
try {
Class.forName(driver);
conn = DriverManager.getConnection(connectionString,
user, pass);
long startTime = System.currentTimeMillis();
singleConnection(conn);
long stopTimeSingle = System.currentTimeMillis();
preparedQuery(conn);
 
Search WWH ::




Custom Search