| From: | Rafal Kedziorski <rafcio(at)polonium(dot)de> | 
|---|---|
| To: | pgsql-jdbc(at)postgresql(dot)org | 
| Subject: | JDBC vs. Entity Bean with JBoss | 
| Date: | 2003-02-14 16:10:26 | 
| Message-ID: | 3E4D14F2.5080407@polonium.de | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | 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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bruce Momjian | 2003-02-14 18:33:44 | Re: PostgreSQL JDBC Drivers licensing? | 
| Previous Message | Alpana Dubey | 2003-02-14 16:00:03 | How to unsubscribe |