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.

Saturday, March 10, 2007

XMLHTTPResponse.status = 0

I am getting XMLHTTPResponse.status = 0 sometimes in my Ajax calls.

Anybody's insight as to why this is happening is much appreciated.

Wednesday, March 7, 2007

Ajax/Web Application Development

I am trying to research different Ajax/Comet technologies, but there is so much disparate information and crossover, that I am having trouble classifying them according to my needs. This blog is an attempt to create a classification of the different Ajax/Comet development tools available. I am just going to throw some things out there and see what evolves...


General technologies:

  • Ajax - A method of asynchronous communication between a browser and server that enables parts of DHTML pages to be updated without a full page refresh.
  • Comet - A method of communication between a browser and server that enables a communication channel to be kept open so a server can continually update the browser without client-side requests.

Javascript widget/component libraries:

  • Dojo - Client side javascript communicates with [arbitrary server-side code?]. Consists of a Javascript library with several window controls and effects. Supports Ajax.
  • DHTML Goodies - Client side javascript communicates with arbitrary server-side code. Cascade/Tile Windows!
  • Prototype Windows - similar to Dojo and DHTML Goodies. Built on Prototype and script.aculo.us.
  • Rico - similar to Dojo and DHTML Goodies, except no windows. Built on Prototype.
  • Yahoo UI - Client side javascript librar with several window controls and effects. Very complete set of controls and offers some smooth animation effects. Supports Ajax.
  • DWT - similar to Dojo and DHTML Goodies. Modeled after Eclipse SWT.
  • Kabuki AjaxTK - client developer toolkit for Javascript widgets. Uses DWT. Created by Zimbra.

Frameworks:

  • GWT - Google Web Toolkit. A Java library that allows a developer to create a rich browser application entirely in Java code. Translates the Java code into DHTML, XML, and Javascript. Supports Ajax.
  • Echo2 - A complete IDE and code library that allows a developer to create a rich browser application. Similar to GWT in that you develop entirely in [language?], and this is translated to [javascript, dhtml, xml?]. Supports Ajax and Comet.
  • OpenLazlo - Code in Javascript, compile to Flash.
  • Zimbra - ??
  • jMaki - a framework that allows you to wrap javascript widgets in jsp tags. Plugins available for Netbeans and Eclipse. Currently has support for some Dojo, Yahoo UI, and Prototype widgets, but you can create your own. Also provides full access to the html and javascript. (samples seem very slow)
  • ZK - framework that utilizes ZUML to develop web based GUI's. No Javascript or Ajax knowledge required.
  • Struts - A servlet-based Java framework that implements the MVC2 pattern. Consists of the architectural components to implement MVC2 and some additional taglibs that implement special html-based controls. Ajax can be implemented with struts, as Ajax can be used with servlets, but it is not really applicable to say that Struts supports Ajax.
  • Pushlets - A servlet-based Java framework that implements event-based server-side push communication with a browser. A communication channel is kept open between the browser and server so that a server can update the browser continually without a request. Don't know if Ajax is responsible for the communication channel.
  • Ruby on Rails - What are these and why are they so special?

... will update as your comments come in.

I am going to start breaking these up into frameworks, widget/component libraries, ...