import java.io.*; import java.sql.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; public class DriverTest extends HttpServlet { public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); out.println(""); out.println(""); String title = "DB Connection Performace Test"; out.println("" + title + ""); out.println(""); out.println(""); out.println("

" + title + "

"); String driver = request.getParameter("driver"); String trialStr = request.getParameter("trial"); int trial = 100; try { trial = Integer.parseInt(trialStr); } catch (Exception e) { } String driverClassName = null; if (driver != null && driver.equals("jeus")) { driverClassName = "jeus.jdbc.pool.Driver"; } else if (driver.equals("weblogic")) { driverClassName = "weblogic.jdbc.pool.Driver"; } else { driverClassName = "oracle.jdbc.driver.OracleDriver"; } out.println("

Tested Driver: " + driverClassName); out.println("
Tested trial: " + trial + "

"); try { Class.forName(driverClassName); } catch (ClassNotFoundException cnfe) { String msg = "

Class " + driverClassName + " is not found

"; out.println(msg); //out.println(""); //out.println(""); //out.close(); } long totalConnectionTime = 0; long beginTop = System.currentTimeMillis(); for (int i = 0; i < trial; i++) { Connection con = null; Statement stmt = null; ResultSet rs = null; try { long begin = System.currentTimeMillis(); if (driverClassName.startsWith("jeus")) { con = DriverManager.getConnection ("jdbc:jeus:pool:oraclePool", null); } else if (driverClassName.startsWith("weblogic")) { con = DriverManager.getConnection ("jdbc:weblogic:pool:oraclePool", null); } else { con = DriverManager.getConnection ( "jdbc:oracle:thin:@143.248.148.39:1521:ORA805", "system", "manager"); } long end = System.currentTimeMillis(); long diff = end - begin; totalConnectionTime += diff; out.println("
[" + i + "] DB Connection Success, time = " + diff + ", " + con); stmt = con.createStatement(); rs = stmt.executeQuery("select * from customer"); while(rs.next()) { String id= rs.getString(1); String name = rs.getString(2); int age = rs.getInt(3); //out.println("
id = " + id); //out.println("
name= "+ name); //out.println("
age= "+ age); } stmt.close(); con.close(); } catch (SQLException se) { se.printStackTrace(); out.println("
[" + i + "] DB Query failed"); try { if (stmt != null) { stmt.close(); } if (con != null) { con.close(); } } catch (Exception e) { } } } long endBottom = System.currentTimeMillis(); out.println("

### Result Performace ###

"); out.println("

total connection time = " + totalConnectionTime); out.println("
total elapsed time = " + (endBottom - beginTop) + "

"); out.println(""); out.println(""); out.close(); } }