Posts Tagged: Software

Commuting in San Jose and IT podcasts

After three years living in San Jose, I was proven wrong on my assumption that it was impossible to commute in San Jose using public transportation. After careful examination of VTA time tables, and several trial and error attempts, I am now commuting to work, having found some good things about commuting:

  • usually it takes me 40 mins door-to-door. Not too bad, considering that the driving time was something between 15-30 minutes, depending on the luck with the 21! traffic lights between home and work (other than that, the drive was a monotonous 9 miles straight, right turn, 1 mile, arrived);
  • instead of losing 30-60 minutes driving to work every day, I actually found myself with 1h20 of free time to do some productive stuff like reading or listening to podcasts.

Of course there are always drawbacks:

  • the bus runs every 15 mins, light rail every 12 and shuttle bus to IBM about every 30 mins. If I get it right, I get from one place to the other in 40 mins. If I get it wrong a.k.a, lose the first bus or lightrail, it takes at least 30 mins more (have to catch next shuttle, if I get there on time).

But the goal of this post is not really to dicuss about VTA’s schedule, but instead about podcasts, more specifically, IT podcasts. I have been alternating between reading and listening to podcasts during the trip, and the podcast I have been listening to is Software Engineering Radio. It is an excellent podcast, and I’m still in episode 30, so have a lot to go (they have 103 as of today :-) ). However, I’m looking for other series to mix up with this one, and also because I might skip some of the episodes that are not of my interest.

So, what IT podcasts do you listen to and what do you like about them? I recently added two series to amarok, but haven’t listened to any episode yet:

Don’t forget to leave your comment and let me know what are your favorite IT podcats! :-)

Mylyn task manager

When I migrated my development environment to Eclipse 3.4 Ganymede, one of the things that caught my attention on Eclipse’s update website was a plugin called Mylyn. A visit to the website, a look over the webcast and it sounded something promising.

It definitely is! Mylyn is a task manager that changes your IDE context based on tasks. You create a task, add resources to its context and when you activate the task, it hides all the other (unneeded) resources from your views (project/package explorer, outlines, editors, etc…). It provides integration with several task repositories, like Bugzilla and Trac. Unfortunately, it doesn’t provide a connector to Clearcase, but I’m still able to use it in an automated way.

I find the tool really awesome when I do something basic like switching tasks: it just closes all the editor windows and projects in the explorer for the task I’m leaving and opens all the files I was working on for the task I’m switching to. This would take me several minutes to do by myself, so having a tool that does that in 1 second is pretty neat!

Here are some more things I like about Mylyn:

  • ability to customize CVS/SVN checkin comments based on templates. Most, if not all, of my commit comments are in the form of “Bug#xxxxx: 1 line description of the bug and fix”. With Mylyn, I can get the comment populated automatically with information from the associated task.
  • when I (re)activate a task, it positions the cursor in the file and method (if java file) I was working on.
  • I can use the URL feature to link to the Clearcase defect page for each one of my defects
  • dynamically adds resources as we follow method references
  • Mylyn filters unrelated content from all views, but I especially like the end result for the package explorer and outline view. When working with classes that have tens of methods, showing just a handful of them in the outline simplifies things a lot!

And the things I don’t like that much:

  • no connector to Rational ClearCase. I have to copy some notes and Defect info from Clearcase to my task manually.
  • the option to show filtered content only shows content at the same level. I would like to have a “show all” option for when I need to look for some resource.
  • It slows down the system a bit. Not too bad, but I do notice it when I have several eclipse instances running.

Overal, I think Mylyn is a great tool and very useful! Even more if you are working with Bugzilla/Trac projects.

If you want to give it a try, this is Mylyn’s homepage and this is a Mylyn tutorial.

 

JDBC performance tips

If you are into java and database development, you will find this article to be a gold mine: http://www.javaperformancetuning.com/tips/jdbc.shtml

It contains links and summary to tens of other performance articles related with java database application development.

SQLJ and JDBC

As a follow up on my last post comparing Static SQL with Dynamic SQL, I will now post an example of how to run the same code using static and dynamic SQL.

One of my visitors left a comment saying that the scope of static and dynamic SQL in Oracle is different than the one I mentioned. I am not familiar at all with Oracle, but was able to find some information on their documentation where they compare JDBC and SQLJ. Since their concept of static vs dynamic SQL is different from the concept in DB2, so my examples may not make sense for Oracle users. I also found out that although Oracle has had plans to desupport SQLJ in its data server, that support has been reinstated in their 10g release.

The two code samples I will show next are shipped with DB2 (get your free copy of DB2 Express-C) and can be found in the file %DB2FOLDER%/samples/java/sqlj/TbRead.java. I’ll just use one of the several examples in that file, that executes a sub-select statement in the employee table.

Sample code in SQLJ:

#sql cur7 = {SELECT job, edlevel, SUM(comm)
	FROM employeeWHERE job IN('DESIGNER', 'FIELDREP')GROUP BY ROLLUP(job, edlevel)};
while (true){
	#sql {FETCH :cur7 INTO :job, :edlevel, :commSum};
	if (cur7.endFetch()){
		break;
	}
	System.out.print("Job: " + job + " Ed Level: " + edlevel + " Tot Comm: " +commSum);
}

Sample code in JDBC:

Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT job, edlevel, SUM(comm) "
	+"  FROM employee "
	+"  WHERE job IN('DESIGNER','FIELDREP') "
	+"  GROUP BY ROLLUP(job, edlevel)");
	while (rs.next())
	{
	if (rs.getString(1) != null)
		{
		job = rs.getString(1);
		edlevel = rs.getString(1);
		commSum = rs.getString(1);
		System.out.print("Job: " + job + " Ed Level: " + edlevel + " Tot Comm: " +commSum);
		}
	}

Although both styles present different syntax, from a developer’s perspective, the only main difference is than when using JDBC one needs to explicitly fetch the row values into Java variables one by one. A common comment from Java developers is that SQLJ is not really Java (one needs to use annotations instead of java method calls), so they prefer to stick with JDBC.

Like I explained in my previous post, the biggest difference between these two styles (static SQL using SQLJ and dynamic SQL using JDBC) is that the SQL statements in the SQLJ files need to be compiled and bound to the database ahead of runtime. The following diagram illustrates this process:

staticSQL.jpg

After the deployment process, SQLJ execution is simpler than JDBC. While JDBC statements need to be prepared at execution time, SQLJ statements are already compiled and ready to use. The two following diagrams illustrate these differences:

jdbcstatement.jpgsqljstatement.jpg

As you can see, static SQL execution process is much simpler, but it requires a complex deployment process. This is an aspect of database development where there is a clash between DBAs and Developers. While ones – the DBAs – prefer the much more refined security and execution control provided by SQLJ and static SQL, others – the Developers – prefer the easier development process of dynamic SQL in the form of JDBC.

Soon, I will talk here about a new Java Data Access platform that supports the usage of both static and dynamic SQL at runtime (through a JVM property), allowing DBAs and Developers to use dynamic SQL on development and test environments and going with static SQL on the production environment. This way, the development community will get the best of both worlds: ease of deployment during development and testing phase and greater performance and control on the production environment.

If you are looking for a data management and application development tool, you should take a look at the new IBM Data Studio. It is an eclipse-based development environment, free to download and to use and with support to all major RDBMS. Download IBM Data Studio.

Static SQL vs Dynamic SQL

I have been wanting to write a few technical articles here on the blog, so I’ll start with something that is related with what I have been looking into at work: Static and Dynamic SQL.

From the conversations I have had with both DBAs and developers, it is clear that DBAs prefer static SQL, while developers prefer Dynamic SQL.

The difference between static and dynamic SQL is that static SQL needs to be compiled and bound to the database before application runtime, while dynamic SQL is compiled during runtime. Next, I’ll show a list of pros and cons regarding each one. 

Static SQL

Pros:

  • compile at bind time. Since the statement is compiled only once and before we run our workload, we have all the database resources in order to generate the most optimal query execution plan. In DB2, there are 9 levels of optimization, being 5 the default one. When we bing our application package, we can pick the highest optimization level – 9 – and get the most optimal execution plan. Using a higher optimization level requires more resources for the compile phase, but since our workload is not yet running, we can afford this high resources requirement.
  • security. Security is probably the most common reason why people use static SQL instead of dynamic SQL. Static SQL allows the DBA to set authorization at the package level. For example, consider an application package app1, that provides SQL functionality to select employee’s name and address from the table employees. The DBA can five user JOHN execution privileges on package app1, even if user JOHN does not have SELECT authority on table employees. Static SQL provides a much finer layer of security.

Cons:

  • need to bind before runtime. Although binding before runtime usually allows for more optimized access plans, doing this in a test or development environment can be cumbersome.
  • lack of tooling support. most of current IDEs provide coding assistance with support for APIs like JDBC. The lack of support from development tools discourages the use of static SQL.

Dynamic SQL

Pros:

  • IDEs and APIs: using eclipse to develop Java code that interacts with the database using JDBC or JPA is much simpler than developing a SQLJ application.
  • statement caching. Dynamic statement caching avoids the need to compile the same statement multiple times, increasing the performance to values close to static SQL. However, bear in mind that a cache miss will be extremely expensive.
  • better statistics. Because the statement is compiled at runtime, it uses the latest statistics available, contributing to a better execution plan.

Cons:

  • compile at runtime. There are a few reasons why compile at runtime can be a bad thing:

    • every time a statement is executed, it needs to be compiled, increasing the total statement execution time
    • the compile time will account for the total execution time, so using higher optimization levels may slow down the overall performance instead of improving it.
    • because the statement is only compiled at runtime, errors in the SQL statement won’t be detected until runtime.

As you can see, there are several reasons why you would choose one over the other. There is no perfect solution! But if you ask me, I would suggest the following: use Static SQL if security is your main concern and use Dynamic SQL if ease of development is your main concern.

XML and Databases

I just stumbled across an excellent resource regarding XML technology in databases. Ronald Bourret has the most extensive research I’ve seen on the global XML and databases state of the art. It has an extensive list of databases with XML support (native or by means of extenders/adapters) recently updated and several papers on XML and databases

A must read, that I will be consuming over the coming weeks. 

Recent readings

Ruby and libxml in Windows

If you happen to be using Ruby in Windows and need to use libxml and don’t feel like compiling it from the source code, here is an alternative. Charlie Savage did the work himself and provides the binary that you can use instead of compiling your own.

Request for comments on Python and Django APIs for DB2

Antonio Cangiano is one of of the persons involved in the creation of a Ruby and Rails native adapter and vendor supported driver for DB2. He now has a post in his blog requesting comments on Python and Django APIs for DB2

If you use Python or Django with DB2 and would like to make comments that will help creating a high quality DB2 adapter for your programming language, this is your opportunity. Even if you don’t use DB2 yet, but have knowledge on Python database application development, I’m sure you have lots of ideas you would like to contribute. Stop by Antonio’s blog and leave your comments.

Joost server down

joost_server_down.jpgI’ve noticed that Joost website has been very sluggish over the last week (with exception of one day or two) and today the server is down. No website and no joost TV for anyone.

About the service itself, I still have the same idea: quality could be better and content is very very limited. I’ve only been watching some NG shows as I have no major interest on the other available shows. The menus have a nice look and feel and are somewhat user friendly (after the first 2 or 3 times you use them you will now how to access everything). I would like to have the feature of “staying on top” for Joost windowed mode, but it doesn’t seem to exist yet.

I have no invitations yet, but once I have I will respect the request list on my previous post about Joost