-
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
-
So, what is your plan? What have you implemented?
-
Java program
import java.sql.*;
public class Test
{
public static void main(String[] args)
{
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// set this to a MS Access DB you have on your machine
String filename = "p:/java/mdbTEST.mdb";
String database = "jdbc dbc river={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
-
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
-
By sboothman in forum Java
Replies: 2
Last Post: 10-16-2006, 03:22 AM
-
By Kyle Gabhart in forum Java
Replies: 0
Last Post: 11-19-2001, 12:11 AM
-
Replies: 1
Last Post: 08-26-2000, 01:35 AM
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks