View RSS Feed

My Java Tips

  1. Batch updates

    by , 11-11-2011 at 06:41 PM (My Java Tips)
    Updating a record from Java using executeUpdate() method of Statement object is used commonly by JDBC programmers. Thing to note is that this is a costly activity in terms of time, as a database trip is made. As a programmer/developer, our aim should be to write efficient Java code. In this post, I will write about how you can efficiently make several updates.


    Batch update allows us to execute several update statements in a batch. It means only one database trip will be make, thus ...
    Categories
    JDBC
  2. Connectiong To MS Access And Fetching Records

    by , 11-08-2011 at 07:37 PM (My Java Tips)
    JDBC (Java Database Connectivity) is designed to allow user to use SQL(Structured Query Language) to query databases. JDBC makes our tasks easy as it handles all low-level concerns about particular database types. It allows you to query an Access database with exactly the same source code as with an Oracle database.

    JDBC is similar to Microsoft's ODBC with the plus point "Platform Independence". To use JDBC, you need to have database driver to communicate with the database. ...
    Tags: jdbc, sql Add / Edit Tags
    Categories
    JDBC
  3. Wrapping JDBC Objects

    by , 05-25-2011 at 10:55 AM (My Java Tips)
    In Glassfish connection pool has a property called "Wrap JDBC Objects" which can have value true or false. You may define it in domain.xml file.

    This property is defined as: "When set to true, application will get wrapped jdbc objects for Statement, PreparedStatement, CallableStatement, ResultSet, DatabaseMetaData".

    If you follow JDBC specifications, you will be see that obtaining connection using DataSource.getConnection() or other objects like ...
  4. hibernate.connection.rele ase_mode

    by , 05-25-2011 at 10:49 AM (My Java Tips)
    Hibernate JDBC/Connection's property hibernate.connection.release_mode is used to specify when Hibernate should release JDBC connections.

    A JDBC connection is held until the session is explicitly closed or disconnected by default. For a JTA datasource, one should use after_statement to aggressively release connections after every JDBC call. And for a non-JTA connection, it often makes sense to release the connection at the end of each transaction. after_transaction.auto will
    ...
    Categories
    Hibernate
  5. Hibernate logging

    by , 05-21-2011 at 11:36 PM (My Java Tips)
    Hibernate logs various events using Apache commons-logging. Hibernate logs are very interesting to read if you want to do some troubleshooting or performance improvement. Hibernate uses commons-logging service for logging. It actually sends the log to either Log4j or to JDK1.4 logging.

    If you want hibernate to log using Log4j, then put log4j.jar into class path along with log4j.properties. Since log4j has almost become a standard these days, I would advice using that.
    Hibernate ...
    Tags: hql, jdbc, log4j, logging, sql Add / Edit Tags
    Categories
    Hibernate