Fowa London 2009
The Future of Web Apps: http://events.carsonified.com/fowa
http://www.exampledepot.com/egs/java.lang/BasicThread.html
Save to echo-gnu-plot.sh
CODE:
-
echo "set terminal png"
-
echo "set output \"$1.png\""
-
echo "set xlabel \"Request\""
-
echo "set ylabel \"ms\""
-
echo "plot \"$1.txt\" using 10 with lines title \"Response time\""
Run ab
ab -g my-page.txt -n 1000 -c 100 http://mypage.net/
Run
sh echo-gnu-plot.sh my-page
Copy the output
Run
then paste from clip board
see the image my-page.png
ab gnuplot
ab and gnuplot
Copy mysql-connector-java-3114-bin to C:\Program Files\Java\jre1.6.X\lib\ext
JAVA:
-
import java.sql.Connection;
-
import java.sql.DriverManager;
-
import java.sql.SQLException;
-
-
// Notice, do not import com.mysql.jdbc.*
-
// or you will have problems!
-
-
public class LoadDriver {
-
-
-
-
public static void main
(String[] args
) {
-
try {
-
// The newInstance() call is a work around for some
-
// broken Java implementations
-
-
Class.forName("com.mysql.jdbc.Driver").newInstance();
-
conn =
-
-
"user=monty&password=greatsqldb");
-
-
-
-
-
stmt = conn.createStatement();
-
rs = stmt.executeQuery("SELECT foo FROM bar");
-
-
// or alternatively, if you don't know ahead of time that
-
// the query will be a SELECT...
-
-
if (stmt.execute("SELECT foo FROM bar")) {
-
rs = stmt.getResultSet();
-
}
-
-
-
// handle any errors
-
System.
out.
println("SQLException: " + ex.
getMessage());
-
System.
out.
println("SQLState: " + ex.
getSQLState());
-
System.
out.
println("VendorError: " + ex.
getErrorCode());
-
-
}
-
finally {
-
// it is a good idea to release
-
// resources in a finally{} block
-
// in reverse-order of their creation
-
// if they are no-longer needed
-
-
if (rs != null) {
-
try {
-
rs.close();
-
-
-
rs = null;
-
}
-
-
if (stmt != null) {
-
try {
-
stmt.close();
-
-
-
stmt = null;
-
}
-
}
-
}
JAVA:
-
import java.sql.*;
-
-
public class Jdbc10 {
-
public static void main
(String args
[]){
-
-
"Copyright 2004, R.G.Baldwin");
-
try {
-
-
-
-
//Register the JDBC driver for MySQL.
-
Class.forName("com.mysql.jdbc.Driver");
-
-
//Define URL of database server for
-
// database named JunkDB on the localhost
-
// with the default port number 3306.
-
-
"jdbc:mysql://localhost:3306/JunkDB";
-
-
//Get a connection to the database for a
-
// user named auser with the password
-
// drowssap, which is password spelled
-
// backwards.
-
-
-
url,"auser", "drowssap");
-
-
//Display URL and connection information
-
System.
out.
println("URL: " + url
);
-
System.
out.
println("Connection: " + con
);
-
-
//Get a Statement object
-
stmt = con.createStatement();
-
-
//As a precaution, delete myTable if it
-
// already exists as residue from a
-
// previous run. Otherwise, if the table
-
// already exists and an attempt is made
-
// to create it, an exception will be
-
// thrown.
-
try{
-
stmt.executeUpdate("DROP TABLE myTable");
-
-
-
-
"No existing table to delete");
-
}//end catch
-
-
//Create a table in the database named
-
// myTable.
-
stmt.executeUpdate(
-
"CREATE TABLE myTable(test_id int," +
-
"test_val char(15) not null)");
-
-
//Insert some values into the table
-
stmt.executeUpdate(
-
"INSERT INTO myTable(test_id, " +
-
"test_val) VALUES(1,'One')");
-
-
//Get another statement object initialized
-
// as shown.
-
stmt = con.createStatement(
-
-
-
-
//Query the database, storing the result
-
// in an object of type ResultSet
-
rs = stmt.executeQuery("SELECT * " +
-
"from myTable ORDER BY test_id");
-
-
//Use the methods of class ResultSet in a
-
// loop to display all of the data in the
-
// database.
-
System.
out.
println("Display all results:");
-
while(rs.next()){
-
int theInt= rs.getInt("test_id");
-
String str = rs.
getString("test_val");
-
System.
out.
println("\ttest_id= " + theInt
-
+ "\tstr = " + str);
-
}//end while loop
-
-
//Display the data in a specific row using
-
// the rs.absolute method.
-
-
"Display row number 2:");
-
if( rs.absolute(2) ){
-
int theInt= rs.getInt("test_id");
-
String str = rs.
getString("test_val");
-
System.
out.
println("\ttest_id= " + theInt
-
+ "\tstr = " + str);
-
}//end if
-
-
//Delete the table and close the connection
-
// to the database
-
stmt.executeUpdate("DROP TABLE myTable");
-
con.close();
-
-
e.printStackTrace();
-
}//end catch
-
}//end main
-
}//end class Jdbc10