Saturday, July 28, 2007

Yahoo UI

I have been working with Yahoo UI and the Yahoo Maps API lately. The libraries are very impressive. Here is a good blog for Yahoo UI:

http://yuiblog.com/blog/2006/12/14/maps-plus-yui/

The blog helped me get past the basic map loading technique hijacking my entire page.

Yahoo UI is very complete and easy to use. I look forward to delving deeper into the API.

Updated survey

I've updated the tech survey that served as the genesis for this blog. My updates are based on some recent learnings about Yahoo UI.

Wednesday, June 6, 2007

JDBC SQL types vs Oracle SQL types

I have just had a frustrating experience with Oracle and JDBC. Imagine you want to select a set of records from a table that fall between two date/time values, and you want to do this with a prepared statement. Using the standard java.sql.Date and PreparedStatement.setDate() method will not work properly with Oracle 9.

Here's what I had to do:

((OraclePreparedStatement)stmt).setDATE(2, new oracle.sql.DATE(new java.sql.Timestamp(startDate.getTime())));

:D

An explanation:

First, I needed to cast to OraclePreparedStatement to have access to the setDATE() function (as opposed to PreparedStatement.setDate()). The setDATE() function takes the crucial oracle.sql.DATE object that maps between JDBC SQL types and the Oracle DATE SQL type. Think of it this way; I can instantiate oracle.sql.DATE with a java.sql.Date, Timestamp, Time, String or other object, and it will try to map those objects to the Oracle DATE SQL type. In this case, I needed an object that preserved the time information along with the date. Therefore, I instantiated the oracle.sql.DATE object with java.sql.Timestamp. Had I instantiated the DATE object with java.sql.Date, it may have succeeded, but time information would be zeroed out.

The upside to this method is that it is an intuitive way to handle Oracle dates with prepared statements. The downside is its dependence on Oracle JDBC extensions. But, with the right DAO architecture, redesign can be minimal when things change.

An alternative to the previous method would be to map a java.sql.Timestamp object to the DATE field using the following:

stmt.setTimestamp(2, new java.sql.Timestamp(startDate.getTime()));

I am to understand from the Oracle JDBC FAQ that since Oracle 9.2, the Oracle DATE SQL type has been mapped to java.sql.Date. The FAQ calls attention to the fact that there will be conflicts if you depend on time information in a DATE field. The above methods both work with Oracle 9.2.0.6.0, so I am not sure what aspect of functionality will be impacted.

Below is a quick summary:

  • java.util.Date - Holds date and time information; really of no use here other than to get the date/time into the method.
  • java.sql.Date - Corresponds to a generic JDBC DATE SQL type. Holds only the date part (2007-06-06).
  • java.sql.Timestamp - Corresponds to a generic JDBC TIMESTAMP SQL type. Holds date AND time (2007-06-06 02:32:04).
  • Oracle SQL DATE type - Stores date and time information, but no nanoseconds. Previous to Oracle 9.2, mapped to java.sql.Timestamp. Post 9.2, maps to java.sql.Date.
  • Oracle SQL TIMESTAMP type - New in Oracle 9.2. Stores date and time information; includes nanoseconds. Since Oracle 9.2, mapped to java.sql.Timestamp.
  • oracle.sql.DATE - Corresponds to the Oracle DATE SQL type. Holds date and time, but in order to function properly, should be instantiated with a java.sql.Timestamp object that also holds date and time.
  • PreparedStatement.setDate(int, java.sql.Date) - Set a JDBC DATE SQL type field in the prepared statement. Only preserves the date part.
  • PreparedStatement.setTimestamp(int, java.sql.Timestamp) - Set a JDBC TIMESTAMP SQL type field in the prepared statement. Preserves date and time, and can be tricked into setting an Oracle DATE type field with date and time information.
  • OraclePreparedStatement.setDATE(int, oracle.sql.DATE) - Set an Oracle DATE SQL type field in the prepared statement. Preserves date and time. In my opinion, the most intuitive method (once you understand it) to set Oracle DATE fields in prepared statements.

Wednesday, March 21, 2007

OpenLazlo Exploration

I went to the OpenLazlo site recently (http://www.openlaszlo.org/) and tried out the demos. They work very well. As I was looking through the overview to understand how it works, some questions came to mind.

OpenLazlo is a fairly interesting and unique design. Code is developed in Javascript and compiled into Flash. As I was reading, I started to wonder why they would choose this architecture. Who are they trying to appeal to? Flash is a stable and widely supported web design technology. You may find Javascript programmers wishing to wander into the world of Flash, but don't you stand to alienate staunch supporters of either technology? Is Flash performance/functionality so much superior/widely supported compared to Javascript to warrant the need to adopt the different technology? If you know Javascript, why not just use an existing and fully functional Javascript library such as Dojo or DHTML Goodies? Is there any consolation for Flash developers that don't know Javascript?

As I mentioned, the demo widgets worked very well, but there was nothing revolutionary in the functionality when considering the possibilities with other, pure Javascript libraries. Other offerings, such as Google Web Toolkit and Echo2, also choose the code conversion method of bringing rich user interfaces to the web. Developers using these frameworks are able to write purly in Java code and compile to Javascript and DHTML. This may enable Java programmers to venture into the web design arena, but is the transposition of a traditional application programming language on top of a web architecture a flexible enough concept? jMaki takes a different approach, embedding Javascript components in JSP/Servlet Tag libraries. Components can be placed on the page with JSP-type tags. This could be a good solution for the multitude of web designers with less programming skills.

What are your thoughts on these questions? Your personal experiences with these different technologies are welcome.

Tuesday, March 20, 2007

Just registered with Technorati

See my Technorati technical profile here:

Technorati Profile

Great Ajax Blog

This is a great Ajax (and other) blog...

http://www.ajaxian.com/

Monday, March 12, 2007

My Development Environment

This is my development evironment:

  • Eclipse 3.2.2 - Eclipse is a really good IDE with a wealth of plugins. Netbeans has good JSP/Servlet/EJB wizards and integration with Glassfish, but Eclipse foundation has countered that with their own Web Tools Platform (WTP) (http://www.eclipse.org/webtools/main.php). The only problem is that it is a project to install and configure WTP with an existing Eclipse installation. Better to start with the complete bundled package.
  • Glassfish v1 - I switched from Apache to Glassfish due to problems with Ajax on Apache 5.5. So far I am happy with it, but beware the autodeploy mechanism. Some old Javascript became stuck in one of the directories, and it was very difficult to figure out why I could not update it. Eventually, I found the directory with the old .js file and deleted it. Now I just use asadmin deploydir and undeploy.
  • Apache 5.5 - I have used Apache since the beginning. There is a good Eclipse plugin that made servlet development so much easier. The reason I started something else was becuase of the Ajax problem. Maybe v6 will clear up the problem.
  • JDK 6.0 - Just keeping up with the latest.