View RSS Feed

My Java Tips

  1. Retrieving auto generated key (JDBC 3.0)

    by , 11-28-2011 at 06:41 PM (My Java Tips)
    JDBC 3.0 introduces a lot of interesting and exciting features which makes database programming simpler. In this post, I will address how to retrieve auto generated keys using JDBC 3.0.


    To get the key, simply specify in the statement's execute() method an optional flag denoting that you are interested in the generated value. Flags of your interest are: Statement.RETURN_GENERATED_KEYS or Statement.NO_GENERATED_KEYS. Execute the statement and now you can obtain the values of the generated ...
    Categories
    JDBC
  2. Returning multiple results (JDBC 3.0)

    by , 11-28-2011 at 06:38 PM (My Java Tips)
    If you have worked with JDBC 2, you might be knowing that if your statement is returning multiple results, only one ResultSet can be opened at a time. This is a limitation. Good new is that JDBC 3.0 specification allows the Statement interface to support multiple open ResultSets. Lets see hot this can be done.



    Please note that the execute() method closes any ResultSets that were opened from a previous call. To support multiple open results, the Statement interface adds an ...
    Categories
    JDBC
  3. Prepared statement pooling (JDBC 3.0)

    by , 11-28-2011 at 06:35 PM (My Java Tips)
    JDBC 3.0 provides improved connection pooling. This post is all about that.



    It is also possible to pool prepared statements. A prepared statement allows us to keep frequently used SQL statement in a pre-compile form, thus improving performance if that statement is executed multiple times. But there is a dark side of this. Creating a PreparedStatement object introduces a certain amount of overhead. There are some developers sometimes change their object models to increase the ...
    Categories
    JDBC