Archive for the ‘General Technology’ Category

PHP – problem triying to conect with Informix on IIS

I was working on a project which needs PHP talk to Informix database on Windows platform. After installed IBM Informix Client_SDK, included PHP extension php_ifx.dll, and use following command to connect to Informix:

$sync_link_id = ifx_connect($database, $username, $password);

I got following error:

[SQLSTATE=IX 000 SQLCODE=-25560]

If you check Informix document from IBM, you know Environment variable INFORMIXSERVER must be set. We know how to set up environment variable on Unix and Apache, but the question is how to set it up for IIS?

People may first think this could be environment variable on Windows as well. But this is wrong. Informix client is using Registry KEY on Windows platform. Here is the path on a 64bit machine.

HKEY_LOCAL_MACHINE\Software\Wow6432Node\Informix\Environment\

Second, you should have your default server setup under KEY:

HKEY_LOCAL_MACHINE\Software\Wow6432Node\Informix\SqlHosts\

At here, you need to provide HOST, PROTOCOL and SERVICE, so php_ifx knows how to connect to your Informix server.

After set them up, PHP should be able to talk to Informix.

Redirect to Error page in Wicket

I was looking for a solution to redirect to an error page in wicket and found this class , RestartResponseAtInterceptPageException , causes wicket to interrupt current request processing and immediately redirect to an intercept page.

For example,
throw new RestartResponseAtInterceptPageException(new ErrorPage(“User does not have permission to view this screen”));

If you need to redirect to an intercept page without interrupting the current request processing , call RedirectToInteceptPage(Page) instead.

-Dhanya

List files sorted by date in java

File inboxDir = new File(“Path to your directory”);
File[] files = inboxDir.listFiles();
Arrays.sort( files, new Comparator()
{
public int compare(Object o1, Object o2) {
return new Long(((File)o1).lastModified()).compareTo(new Long(((File) o2).lastModified()));
}

});

Using PHP FastCGI mode on Windows Server 2003 x64 w/ IIS in 32-bit mode

I recently needed to upgrade the PHP for a particular site from 5.2.6 to 5.3.0.  Of course, this is when I found out that PHP no longer supports the ISAPI module and instead wants you to use FastCGI.  Luckily I found a great article on how to configure IIS at http://learn.iis.net/page.aspx/247/using-fastcgi-to-host-php-applications-on-iis-60/.  However, these instructions have some caveats in regards to running IIS in 32 bit mode on Windows Server 2003 x64.  To make a long story short, just like with most things running in 32 bit mode on x64, everything that references %WINDIR%\system32 really needs to point to %WINDIR%\SysWOW64.  If you use the fcgiconfig.js script, this will configure everything to point to %WINDIR%\system32.

  • The Web Service Extension needs to point to %WINDIR%\SysWOW64\inetsrv\fcgiext.dll.
  • The .php extension on the website also needs to point to %WINDIR%\SysWOW64\inetsrv\fcgiext.dll.
  • The fcgiext.ini file must also be located in %WINDIR%\SysWOW64\inetsrv.  Otherwise you will get a 500 error from FastCGI saying it cannot find the configuration file.

Note that the fcgiconfig.js script is only installed in %WINDIR%\system32\inetsrv.  I was able to create a fcgiconfigwow64.js file that points to the correct files.  The script needs to have at least an ini file with the “[Types]” section in the %WINDIR%\SysWOW64\inetsrv directory.  It also needs to be located under %WINDIR%\system32 as it doesn’t support running under Wow64.  You just need to change the following 2 lines near the top of the script.

From:

var g_iniPath       = g_Shell.ExpandEnvironmentStrings( "%WinDir%\\system32\\inetsrv\\fcgiext.ini" );
var g_extensionPath = g_Shell.ExpandEnvironmentStrings( "%WinDir%\\system32\\inetsrv\\fcgiext.dll" );

To:

var g_iniPath       = g_Shell.ExpandEnvironmentStrings( "%WinDir%\\SysWOW64\\inetsrv\\fcgiext.ini" );
var g_extensionPath = g_Shell.ExpandEnvironmentStrings( "%WinDir%\\SysWOW64\\inetsrv\\fcgiext.dll" );

Unidev Employees Attend St. Louis Day of .NET Conference

The second annual St. Louis Day of .NET conference was held on August 28th and 29th, 2009. Over 500 local .NET developers, architects and other technologists, including Unidev’s George Zheng and Jinhai Wang, attended the highly anticipated event at the exciting location of The Ameristar Casino in St. Charles, Missouri. The conference, with too much info to pack into just one day, had over 50 technical sessions from local and national experts on Saturday and Sunday covering all the technologies of today, as well as providing a sneak preview of the technology possibilities of the future.

George and Jinhai took a lot of useful information from the conference and were exposed to new skills and ideas. “Day to day we use the various Microsoft Tools to focus on one project, but the conference covered every aspect of the tool. Meeting with other users of the same tools, helped me to become quicker, more educated and more productive,” George Zheng says of his experience at the conference.

Jinhai found the session on Language Integrated Query (LINQ), presented by Keith Dahlby, Senior Consultant at Inetium, to be most impressive. The session explored technologies that make LINQ possible and discussed how you can use the same techniques to make LINQ work for you. Another session Jinhai and George both found notable was the session on Silverlight presented by Brad Tutterow, Senior Consultant at Daugherty Business Solutions. Silverlight is a browser plug-in that allows .NET developers to write rich internet applications (RIAs). The session covered how to use Visual Studio and the Expression Studio suite together to build a working Silverlight game, the outcome of the presentation was a working Silverlight game that participants got to take home with them.

A few of the session topics covered at the conference included C #, VB.NET, Sharepoint, WPF, WCF, Visual Studio, .NET 4.0, Expression Blend, SQL Server 2008, ASP.NET MVC and Windows Azure. In an effort to provide the most rewarding experience possible to participants, this year’s conference offered a wide variety of alternative sessions and other unique opportunities such as roundtable discussions, “Birds of a Feather” opportunities, a vendor fair and a Friday night social at Home Night Club, located in the Ameristar Casino.

George and Jinhai both saw the .NET Conference as a success and found the experience to be extremely beneficial to their work at Unidev. They are looking forward to what the St. Louis Day of .NET 2010 Conference has in store!

Bidirectional Associations and JiBX

I recently needed to use JiBX to parse a XML document into domain objects that contained bidirectional associations with collections.  The issue started out as a simple NullPointerException since each child object did not have a reference back to its parent. 

After some searching on Google, the only suggestions that I came across had to do with using the post-set attribute, which gets called after the class has been unmarshalled.  For various reasons, most of which I did not want the domain classes tied to JiBX, I sought out a different solution.

The solution I came up with was to use a set-method for the collection instead of field.  So I replaced field=”fieldName” with set-method=”setFieldName”.  This set method ensures that the bidirectional association is properly defined. 

There is an argument to be made that I should be doing this anyway.  After all, the domain class probably should not let it be up to the caller to ensure the bidirectional association is properly defined, regardless if it is being called from JiBX or some other caller.

However there was one unintentional side affect.  The project is also using Hibernate.  The same domain classes were mapped using lazy associations.  This change to the set method in affect turned off the laziness.  The solution for this was to change the Hibernate mappings to use field access to bypass the set method.

Paging the query result

If you have 5000 products in database, you may like to show them in pages on the screen. It’s a common request to only retrieve the records on a certain page. This query must be quick and efficient if we are talking about millions of records in a table for an AJAX control.

In Oracle, we can do this:

SELECT * from
(
SELECT *, ROWNUM as rownumber from Product order by name
)
where rownumber between (PageNbr - 1)*PageSize + 1 and PageNbr*PageSize

As you can see, this query needs to fetch all rows first then narrows down the result. A more efficient query is:

select *
from ( select a.*, rownum rnum
from ( select * from product order by name) a
where rownum <= PageNbr*PageSize)
where rnum >= (PageNbr - 1)*PageSize + 1

Oracle will optimize this query, so it is not as resource intensive as the first one.

In SQL Server 2005, we can do similar query:

WITH Temp AS
(
SELECT row_number() OVER (ORDER BY [name]) AS rowNum, * from Product
)
SELECT * FROM Temp
WHERE rowNum between (@PageNbr - 1) * @PageSize + 1 and @PageNbr * @PageSize
ORDER BY [name]

The query had been optimized in SQL Server as well.

Google App Engine is open for Java Now

 Google App Engine Java Overview.

You can sign up here.

XMarks Smarter Search feature on IE8 produces mixed content warning

I just installed XMarks to see if I can start synchronizing my bookmarks between all of my various locations and all the browsers installed.  However soon after installing, I noticed that I would get the mixed content warning (the one telling you are downloading unsecure content from a secure page) every time I would go to our company portal page, which is always secured via SSL.

I double checked the sites using Firefox, and even IE 7 from another machine, and the warning did not appear.  I disabled the Smarter Search feature in XMarks and the warning went away.

I have only installed XMarks on IE 8 so I don’t know if it is specific to IE 8 or is a problem with other browsers in general.

Update:  As per Colin below this issue has been fixed with version 1.0.7.  I installed this version and the warning no longer appears.  It is refreshing to have such a quick response.

The Four Pillars of ASP.NET

Paul Litwin posted an interesting article that discusses the four pillars of ASP.NET (Web Forms, MVC, AJAX, and Dynamic Data).

He said: “Microsoft used to present ASP.NET Web Forms vs. MVC as a choice between a car and a motorcycle. Both will get you to your job , but some (the majority of the population, I might add) prefer driving a car, while a sizable minority love their motorcycles which give you better gas mileage and independence, but don’t protect you in the rain. To stretch this analogy to its breaking point, let me suggest that ASP.NET AJAX is like riding a bicycle to work (lean and mean, best gas mileage, but it requires you to exercise for your commute and exposes you to the elements like the motorcycle) while Dynamic Data is like taking the bus to work (let metro do the driving for you.)”

You can read his blog entry here: