테스트 사양
P-4 : 1.6
RAM : 512
DB : MySQL 3.23.25 for window
OS : Windows2000 Server
============================================
간단한 insert 소스
----------------------------------------------------

import java.sql.*;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/

public class DBTest4 {
        String name = null;
        String title = null;
        String track = null;

        public void init() {
                Connection conn = null;
                PreparedStatement stmt = null;
                
                try {
                        Class.forName("org.gjt.mm.mysql.Driver");
                }catch (ClassNotFoundException ex) {
                        System.err.println("ClassNotFoundException: " + ex.getMessage());
                }

                try{
                        
                        String sql = "insert into musictest values(?, ?, ?, ?, ?)";
                        conn = DriverManager.getConnection("jdbc:mysql://localhost/music","music","music");
                        
                        for(int i=1; i <= 50000; i++){
                                stmt = conn.prepareStatement(sql);
                                stmt.setString(1, "jacksun"+i);
                                stmt.setString(2, "i love you"+i);
                                stmt.setString(3, "2002");
                                stmt.setString(4, "musician1"+i);
                                stmt.setString(5, "musician2"+i);
                                stmt.executeUpdate();
                                System.out.println("count : "+i);
                        }
                                                                
                        conn.close();
                }catch(Exception e) {
                          e.printStackTrace();
                }finally {
                        if ( stmt != null ) try{stmt.close();}catch(Exception e){}
                        if ( conn != null ) try{conn.close();}catch(Exception e){}
                }
        }

        public static void main(String[] args) {
                DBTest4 db = new DBTest4();
                db.init();
        }
}

==============================================
select 소스
----------------------------------------------------


import java.sql.*;
import java.util.Vector;

/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: </p>
* @author not attributable
* @version 1.0
*/

public class DBTest2 {
        
        Vector result = new Vector();
        
        public void init() {
                
                long start_full = System.currentTimeMillis();
                
                String musician, music_subject, music_year, music_write, music_compose = null;
                Connection conn = null;
                Statement stmt = null;
                
                try {
                        Class.forName("org.gjt.mm.mysql.Driver");
                }catch (ClassNotFoundException ex) {
                        System.err.println("ClassNotFoundException: " + ex.getMessage());
                }

                try{
                        conn = DriverManager.getConnection("jdbc:mysql://localhost/music","music","music");

                        if(conn != null)  {
                                stmt = conn.createStatement();
                                
                                long start = System.currentTimeMillis();

                                ResultSet rst = stmt.executeQuery("select musician, music_subject, music_year, music_write, music_compose from musictest");                                
                                
                                long end = System.currentTimeMillis();
                                double res1 = (double)(end - start) / 1000;
                                //System.out.println("start1 : "+start);
                                //System.out.println("end2  : "+end);
                                System.out.println("res1  : "+res1+"초");
                                
                                long start2 = System.currentTimeMillis();
                                
                                while(rst.next()) {
                                        musician = rst.getString(1);
                                        music_subject = rst.getString(2);
                                        music_year = rst.getString(3);
                                        music_write = rst.getString(4);
                                        music_compose = rst.getString(4);
                                        
                                        Vector row = new Vector();
                                        row.add(musician);
                                        row.add(music_subject);
                                        row.add(music_year);
                                        row.add(music_write);
                                        row.add(music_compose);
                                        result.add(row);
                                }
                                conn.close();
                                long end2 = System.currentTimeMillis();
                                double res2 = (double)(end2 - start2) / 1000;
                                
                                //System.out.println("start1 : "+start2);
                                //System.out.println("end2  : "+end2);
                                System.out.println("res2  : "+res2+"초");                                
                        }
                }catch(Exception e) {
                          e.printStackTrace();
                }finally {
                        if ( stmt != null ) try{stmt.close();}catch(Exception e){}
                        if ( conn != null ) try{conn.close();}catch(Exception e){}
                  }

                
                long end_full = System.currentTimeMillis();
                double res_full = (double)(end_full - start_full) / 1000;
                System.out.println("res_full  : "+res_full+"초");
        }
        
        public Vector getResult(){                
                return result;        
        }                
        
        public static void main(String[] args) {
                
                DBTest2 db = new DBTest2();
                db.init();
                Vector result = db.getResult();
                
                long start = System.currentTimeMillis();
                for(int i=0; i < result.size(); i++){
                        Vector row = (Vector)result.get(i);
                        
                        String musician = (String)row.get(0);
                        String music_subject = (String)row.get(1);
                        String music_year = (String)row.get(2);
                        String music_write = (String)row.get(3);
                        String music_compose = (String)row.get(4);
                                                
                }
                long end = System.currentTimeMillis();
                double res2 = (double)(end - start) / 1000;
                //System.out.println("start2 : "+start);
                //System.out.println("end2  : "+end);
                System.out.println("res3  : "+res2+"초");
        }
}

=======================================

결과는 이어서 계속 ...




***** 아름다운프로님에 의해서 게시물 복사 + 카테고리변경되었습니다 (2003-12-18 17:44)
Posted by 아름프로
BLOG main image

카테고리

분류 전체보기 (539)
이야기방 (19)
토론/정보/사설 (16)
IBM Rational (9)
U-IT (0)
SOA/WS/ebXML (110)
개발방법론/모델링 (122)
J2SE (34)
J2EE (60)
DataBase (39)
Open Projects (30)
BP/표준화 (50)
Apache Projects (15)
Web/보안/OS (22)
Tools (7)
AJAX/WEB2.0 (1)
Linux/Unix (1)
영어 (0)
비공개방 (0)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

달력

«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

글 보관함

Total :
Today : Yesterday :