JDBC Performance : Metadata DB Info « Database SQL JDBC « Java

Java
1. 2D Graphics GUI
2. 3D
3. Advanced Graphics
4. Ant
5. Apache Common
6. Chart
7. Class
8. Collections Data Structure
9. Data Type
10. Database SQL JDBC
11. Design Pattern
12. Development Class
13. EJB3
14. Email
15. Event
16. File Input Output
17. Game
18. Generics
19. GWT
20. Hibernate
21. I18N
22. J2EE
23. J2ME
24. JDK 6
25. JNDI LDAP
26. JPA
27. JSP
28. JSTL
29. Language Basics
30. Network Protocol
31. PDF RTF
32. Reflection
33. Regular Expressions
34. Scripting
35. Security
36. Servlets
37. Spring
38. Swing Components
39. Swing JFC
40. SWT JFace Eclipse
41. Threads
42. Tiny Application
43. Velocity
44. Web Services SOA
45. XML
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java » Database SQL JDBC » Metadata DB InfoScreenshots 
JDBC Performance

/*

MySQL and Java Developer's Guide

Mark Matthews, Jim Cole, Joseph D. Gradecki
Publisher Wiley,
Published February 2003, 
ISBN 0471269239

*/



import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Date;

public class Performance {
  Connection connection;

  public Performance() {
    try {
      Class.forName("com.mysql.jdbc.Driver").newInstance();
    catch (Exception e) {
      System.err.println("unable to load driver");
    }
    try {
      connection = DriverManager
          .getConnection("jdbc:mysql://192.168.1.81/archives?user=archives&password=archives");
    catch (SQLException e) {
      System.out.println("SQLException: " + e.getMessage());
      System.out.println("SQLState: " + e.getSQLState());
      System.out.println("VendorError:  " + e.getErrorCode());
    }
  }

  public void run() {
    long startTime;

    try {
      /*
       * PreparedStatement ps = connection.prepareStatement("INSERT INTO
       * product VALUES(null, 'title', 5.54, 'supplier', null, ?)");
       * startTime = new Date().getTime(); for (int i=0;i <1000;i++) {
       * ps.setInt(1, i); ps.executeUpdate(); } System.out.println("INSERT = " +
       * ((new Date().getTime()) - startTime));
       */
      Statement statement = connection.createStatement();
      startTime = new Date().getTime();
      for (int i = 0; i < 60; i++) {
        ResultSet rs = statement
            .executeQuery("SELECT pic_id, length, tlength, ts FROM them limit 100, "
                (i * 1000));
        rs.close();
      }

      //      ResultSet rs = statement.executeQuery("SELECT pic_id, length,
      // tlength, ts FROM them");
      //      rs.close();

      statement.close();
      System.out.println("SELECT = "
          ((new Date().getTime()) - startTime));

      /*
       * ps = connection.prepareStatement("UPDATE product SET inventory=10
       * WHERE inventory = ?"); startTime = new Date().getTime(); for (int
       * i=0;i <1000;i++) { ps.setInt(1, i); ps.executeUpdate(); }
       * System.out.println("UPDATE = " + ((new Date().getTime()) -
       * startTime));
       */
      connection.close();
    catch (SQLException e) {
    }
  }

  public static void main(String[] args) {
    Performance test = new Performance();
    test.run();
  }
}
           
       
Related examples in the same category
1. Get all key words in database
2. Get Database Schema From MetaData
3. Get Catalog From Database Metadata
4. Is statement pooling supported?
5. Database MetaData: Database version
6. Type info in database metadata
7. A database MetaData query
8. DatabaseMetaData class to obtain information about the
9. Database Info
10. Driver Property Info
11. JDBC Version App
w___w___w__.j___a__v__a___2___s._c__om__ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.