JDBC vs. Entity Bean with JBoss - Mailing list pgsql-jdbc
From | Rafal Kedziorski |
---|---|
Subject | JDBC vs. Entity Bean with JBoss |
Date | |
Msg-id | 3E4D14F2.5080407@polonium.de Whole thread Raw |
Responses |
How to unsubscribe
(Alpana Dubey <alpanad@iitk.ac.in>)
|
List | pgsql-jdbc |
hi, I'm using currently cygwin with pg7.3.2 (default installation without optimisations), JDK1.4.1_01, JDBC driver for J2SE 1.4 und JBoss 3.0.6. I done some test. create 1000 entries in the same table (id field - number(20), name filed varchar(40)) JBoss with EJB needed 54 sec. JBoss with direct SQL needed 47 sec. why is sql only 7 seconds faster? the CPU usage was about 12%. pg and jboss are running on the same computer. and here the code: private void createFirmSQL(ServletOutputStream out) throws IOException { Connection con = null; PreparedStatement pstmt = null; ResultSet rs = null; try { con = getConnection(); if (con != null) { String query = "insert into firm values(?,?)"; pstmt = con.prepareStatement(query); long start = System.currentTimeMillis(); for (int i = 0; i < N; i++) { // getUniqueLongID need for creating 1.000.000 keys about 7 seconds. pstmt.setLong(1, SQLUtilities.getUniqueLongID().longValue()); pstmt.setString(2, "name " + i); // commit every time like ejb pstmt.executeUpdate(); } long end = System.currentTimeMillis() - start; out.println("needed " + end + " for creating " + N + " entries in firm table thru sql"); } } catch (SQLException sqle) { } finally { SQLUtilities.getInstance().closeConnections(con, pstmt, rs); } } private void createFirmEJB(ServletOutputStream out) throws IOException { // testing entity beans ServiceLocator serviceLocator = ServiceLocator.getInstance(); FirmLocalHome firmHome = null; try { firmHome = (FirmLocalHome) serviceLocator.getLocalHome(JNDINamesAccess.FIRM_EJB); long start = System.currentTimeMillis(); for (int i = 0; i < N; i++) { // firm used the same keygenerator like above FirmLocal firm = firmHome.create("name " + i); } long end = System.currentTimeMillis() - start; out.println("needed " + end + " for creating " + N + " entries in firm table thru ejb"); } catch (ServiceLocatorException sle) { } catch (CreateException ce) { } } Best Regards, Rafal
pgsql-jdbc by date: