Software Development

A blog about software development, primarily in Java and about web applications.

Thursday, June 20, 2013

Oracle Table Statistics

I traditionally used "analyze table owner.table_name compute statistics;". I believe, this analyzes the table and its indexes and checks every row rather than just a sample of rows (thus giving an accurate count in NUM_ROWS). However, Oracle now says that "analyze table" is outdated. DBMS_STATS replaces it. When I'm checking table statuses, I typically use queries such as "select table_name, num_rows, last_analyzed from user_tables where trunc(last_analyzed) = trunc(sysdate) order by 3" to find everything that has been analyzed today, in order of analysis time. I think that this sort of query also works with materialized views.

Wednesday, March 6, 2013

Subversion (SVN) Merging From The Command Line

It is usually pretty straight forward to merge fixes from a branch into the trunk using SVN. Here is a SVN command line example.
  1. Check out a pristine up-to-date trunk or use a workspace with no modifications.
  2. svn merge https://svn.myorg.com/repos/devteam/myproject/branches/v7.00.4@HEAD .
    $ svn merge https://svn.myorg.com/repos/devteam/myproject/branches/v7.00.4@HEAD .
    --- Merging r110205 through r110328 into '.':
    U    src/java/edu/stanford/irt/frd/layout/StaffLayout.java
    U    src/java/edu/stanford/irt/frd/layout/Layout.java
    U    src/web/social/profileUserfeed.jsp
    U    src/web/public/menlo_profile_printer.jsp
    
  3. verify the merge fixes things locally
  4. commit the changes to the trunk. SVN will keep track of what has already been merged so that future merges are also easy to do.
    $ svn commit -m "Merging 4.0.1 bug fixes into trunk"
    Sending        .
    Sending        src/java/edu/stanford/irt/frd/layout/Layout.java
    Sending        src/java/edu/stanford/irt/frd/layout/StaffLayout.java
    Sending        src/web/public/menlo_profile_printer.jsp
    Sending        src/web/social/profileUserfeed.jsp
    

Thursday, August 23, 2012

Unix Command - watch

I'm sitting here waiting for a huge rsync to complete over a slow network from slow disks to what I hope are faster disks.  To monitor the progress, I'm using the Unix watch command to periodically run a du on the directory being written to.  This gives me an idea of its growth and how far along I am:

watch --interval=1 du -sm /hudson

The -sm options to du just tell it to summarize the size in MB.

Monday, April 9, 2012

Externally Configuring Application Properties with Spring

I posted on another method for doing this a while back and this alternate approach was sent me some time ago so I thought I would share it here.  The issue trying to be addressed is the ability to deliver a single WAR file to multiple environments that each may need different configurations.  For example, a QA environment, an automated testing environment, a developer's personal environment, a customer's installation, or a hosted production instance.  To do this you need to externalize your applications configuration or build a UI and maintain the configuration in your database.  Using property files is a simple approach and works quite well and has some advantages over the database approach if your application instances are ephemeral.
You can have a default properties file and afterwards overwrite it with a file that is external to your application. The "properties overwrite file" is optional
<bean id="propertyConfigurer" 
 class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
 
</bean>
 

<bean id="propertyOverrideConfigurer"
        class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
       
          
</bean>
References:
  1. http://static.springsource.org/spring/docs/2.5.x/reference/xsd-config.html 
  2. http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-factory-overrideconfigure