DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2006

    Java program to compare performance

    Using any source of data, develop a program which can compare the performance of any two of the following techniques:
    (i) JDBC direct connection to database
    (ii) Direct socket connection - data held in memory
    (iii) CORBA connection

    NB comparison could be througput in seconds

    Please help me get this program

  2. #2
    Join Date
    Dec 2004
    San Bernardino County, California
    So, what is your plan? What have you implemented?

  3. #3
    Join Date
    Nov 2006

    Java program

    import java.sql.*;
    public class Test

    public static void main(String[] args)


    try {
    // set this to a MS Access DB you have on your machine
    String filename = "p:/java/mdbTEST.mdb";
    String database = "jdbcdbcriver={Microsoft Access Driver (*.mdb)};DBQ=";
    database+= filename.trim() + ";DriverID=22;READONLY=true}"; // add on to the end
    // now we can get the connection from the DriverManager
    Connection con = DriverManager.getConnection( database ,"","");
    Statement s = con.createStatement();
    s.execute("create table TEST12345 ( column_name integer )"); // create a table
    s.execute("insert into TEST12345 values(1)"); // insert some data into the table
    s.execute("select column_name from TEST12345"); // select the data from the table
    ResultSet rs = s.getResultSet(); // get any ResultSet that came from our query
    if (rs != null) // if rs == null, then there is no ResultSet to view
    while ( rs.next() ) // this will step through our data row-by-row

    /* the next line will get the first column in our current row's ResultSet
    as a String ( getString( columnNumber) ) and output it to the screen */
    System.out.println("Data from column_name: " + rs.getString(1) );

    s.execute("drop table TEST12345");
    s.close(); // close the Statement to let the database know we're done with it
    con.close(); // close the Connection to let the database know we're done with it

    catch (Exception err) {
    System.out.println("ERROR: " + err);


    //save this code into a file called Test.java and compile it

    I have this program for JDBC connection to an access database, I will like to know how many seconds it takes to connect to the database, I also want another connection this time using rmi and how many seconds it also takes to connect so that I can compare which of them is faster

  4. #4
    Join Date
    Dec 2004
    San Bernardino County, California
    That looks like a good start. Remember you are going to need to start and stop a timer, too. It would be a good idea to have an interface whose functions you call, then put various implementing classes in its place which implement those functions - that way your testing structure is the same and the only thing that changes is the implementation - this is a use of the "Strategy" pattern.

    Now, how do you connect using RMI, to do the same thing that the JDBC connection does?

Similar Threads

  1. Logging Java Program
    By sboothman in forum Java
    Replies: 2
    Last Post: 10-16-2006, 03:22 AM
  2. Replies: 0
    Last Post: 11-19-2001, 12:11 AM
  3. Replies: 1
    Last Post: 08-26-2000, 01:35 AM
  4. Replies: 1
    Last Post: 06-23-2000, 08:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
Latest Articles
Questions? Contact us.
Web Development
Latest Tips
Open Source

   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.