1. steps
    1. import the required packages
    2. register the jdbc drivers
      1. Class.forName("com.mysql.jdbc.Driver");
    3. open a connection to a database
      1. DriverManager.getConnection();
    4. create a statement object
    5. execute a query and return a ResultSet object
    6. process the ResultSet object
    7. close the ResultSet and Statement Objcet
    8. close the connnection
  2. architecture
    1. jdbc
      1. pic
      2. core
    2. performance
      1. select the right JDBC driver
      2. simplify sql queries
      3. minimizing the use of database metadata methods
      4. manage database connection objects
        1. setting optimal connection properties
        2. setting an optimal row prefetch value
        3. using a connection pool
          1. example
          2. connect once and using multiple statement objects
        4. controlling a transaction
          1. many statement object executed as a single unit
        5. choosing the optimal transaction isolation level
          1. transaction level
          2. TRANSACTION_NONE-0
          3. TRANSACTION_READ_UNCOMMITTED-1
          4. TRANSACTION_READ_COMMITTED-2
          5. TRANSACTION_REPEATABLE_READ-4
          6. TRANSACTION_SERIALIZABLE-8
      5. avoding using generic search patterns
        1. example
      6. retrieving only required data
        1. return the only columns you need
        2. set driver specific methods
          1. Statement.setMaxRows
          2. Statement.setMaxFieldSize
          3. ResultSet.setFetchSize
          4. Statement.setFetchSize
      7. Statement or PrepareStatement
        1. Statement
        2. PrepareStatement
          1. http://www.javaeye.com/topic/49129?page=3
      8. choose the right cursor
        1. ResultSet.TYPE_FORWARD_ONLY
        2. ResultSet.TYPE_SCROLL_INSENSITIVE
        3. ResultSet.TYPE_SCROLL_SENTITIVE
      9. caching PreparedStatement Objects
        1. PreparedStatement object pooling to cache rarely changed sql or queries
    3. tiers
      1. 2 tiers
        1. pic
      2. 3 tiers
        1. pic
  3. API
    1. java.sql
      1. elements
        1. DriverManager
          1. driver
          2. jdbc-odbc
          3. pic
          4. not recommended
          5. experimental
          6. not as fast as jdbc
          7. do not support multiple concurrent open statements
          8. not support Blob and Clob
          9. install
          10. how to load
          11. Class.forName("com.mysql.jdbc.Driver");
          12. DriverManager.registerDriver(new com.mysql.jdbc.Driver());
          13. instance a Driver class
          14. use System.properties()
          15. java -Djdbc.drivers=com.mysql.jdbc.Driver:sun.jdbc.odbc.JdbcOdbcDriver Test
          16. use a thread class
          17. type
          18. JDBC-ODBC
          19. some ODBC native code must be loaded on each client machine
          20. pic
          21. native-API
          22. requires some binary code be loaded on each client machine
          23. pic
          24. network-protocol
          25. translate JDBC API calls into a DBMS-independent net protocol
          26. pic
          27. native-protocol
          28. convert JDBC calls into the network protocol used by DBMS directly
          29. pic
          30. select criteria
          31. features and ease of use
          32. speed/performance
          33. reliability
          34. security
          35. protability
          36. support
          37. price
          38. open source
          39. compatibility
        2. Connection
          1. URL
          2. jdbc:mysql://localhost/db1
          3. pic
          4. Class.forName()
          5. unicode
          6. datasource
          7. JNDI
          8. PIC
          9. benefits
          10. properties
          11. pic
          12. create DataSource Object
        3. Statement
          1. execute()
          2. executeBatch()
          3. executeQuery()
          4. executeUpdate()
        4. PreparedStatement
          1. example
        5. CallableStatement
        6. ResultSet
          1. get index start from 1
          2. get table row count
        7. SQLExcepiton
    2. javax.sql
      1. DataSource to establish a connection
      2. Connection pooling
        1. benefits
          1. limited connections
          2. performance
        2. interface
          1. ConnectionPoolDataSource
          2. PooledConnection
        3. products
          1. Apache Avalon/Excalibur
          2. Commons Pool
          3. commons DBCP
      3. Distributed transactions
      4. Row sets
    3. metadata
      1. DatabaseMetaData
      2. ResultSetMetaData
      3. ParameterMetaData
      4. RowSetMetaData
    4. transaction
      1. default autocommit is true
        1. sql statements are executed and committed as individual transaction
        2. for every single statement, a transaction begins-->execute the statement successfully-->commit
      2. conn.setAutoCommit(false);
      3. rollback
        1. any point before committing a transaction
        2. conn.rollback();
      4. how to start
        1. explicit
        2. then set autocommit back to true
    5. debug
      1. DriverManager.setLogWriter(pw);
  4. special
    1. data type
      1. Blob
      2. Clob
      3. Date/Time/Timestamp