Databases Reference
In-Depth Information
useStoredProcedure(conn);
long stopTimePrep = System.currentTimeMillis();
System.out.println(
String.format("Execution without prepared query %dms.
\nExecution with prepared query %dms.",
(stopTimeSingle - startTime),
(stopTimePrep - stopTimeSingle)));
} catch (Exception e) {
System.out.println(String.format("Error %s",
e.getLocalizedMessage()));
System.exit(1);
} finally {
conn.close();
}
}
}
6. Open a terminal and make chapter02 as the current directory.
7. Build the program by using the following command:
javac StoredProcedure.java
8. Open a terminal and make OraclePerformanceTuningCookbook as the
current directory. Run the program from the command line:
java chapter02.StoredProcedure
The output will be as follows:
...
126 370204.56
127 1033311.97
16 2082330.3
122 84498.67
139 244595.65
Execution without prepared query 1438ms.
Execution with prepared query 1722ms.
How it works...
Let me explain the script. First we create a stored procedure that returns a cursor, querying
the amount of sales of a product. The stored procedure is compiled, so when it is called later,
the compilation phase will not be re-executed.
 
Search WWH ::




Custom Search