Lets make IT better by sharing the solutions

Monday, July 28, 2008

SQL Server Date Problem

In java if you are using SQL Server you might come across an error like:
java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Optional feature not implemented
The problem is that there is no Date datatype for SQL Server rather we have DATETIME whose JDBC Equivalent is java.sql.Timestamp.
So, to use setDate method we need to pass java.sql.Timestamp as date.
Note : For mySQL and many other databases we are fine with Date

Friday, July 18, 2008

Multilanguage Support to Struts

As we have heard so many time that sturs i a frame work which provide multilingual support very easly.Its true for those languages which supports ascii characters.For Arabic like languages its not that easy. There is one standard characterset format that is UTF-8,which supports many languages including Arabics also. So while developing multilanguage application one has to concentrate on characterset which s UTF-8.Talking About java which is UTF-16 by default so we will not get the proper result simply. Following are the steps involved in making it UTF-8 centric.
The .properties file for that language should be converted into UTF-8 format using
native2ascii utility of jdk.
the spl character written on the page will display like \uXXX\uYYY.
Now make your jsp page able to present in UTF-8 format by setting charset as UTF-8.
Now set the request encoding to UTF-8.
If you are using database make sure charecterset variable of you db is set to UTF-8.
Also the database shold be created after setting characterset.
Its done now.
For detail code contact me on mail....mailid:mydesires100@gmail.com

Monday, July 14, 2008

Trapping Window Close for Internet Explorer

Today i come across a scenario where , if the close button of internet explorer is clicked and i need to call a logout action to have safe signout.So i scroll through internet all the way , I came to know about so many ways but non of them worked for me . But i got the clue how to proceed , I proceed as
Place the follwing java script code on your page between script tag

function whileClosing() {
if((window.event.clientX>1000)(window.event.clientY<-100)) {
document.forms[0].action="<%=sLinkPrefix%>/logoutAction.do";
document.forms[0].submit(); }
else { alert("Refresh"); }
}
window.onunload=whileClosing;
Here clientX,clientY is the location where the click is done so better you alert these locations and check what are the coordinated of close button,
Note : This might be different Coordinated for other Resolutions.Please check to trap the resolutions of your system and let me know if you are done.

Thursday, July 10, 2008

Java Collection 1

Collections in java has been provided to have the better approach for managing your data and and their representation. By data we mean the contentent and by representation we mean how you cordinate your data to use it efficiently.
Now the Question arises why use collection , collection is kind of low level implementation so to let the programmers concentrate on their main logics rather than putting them busy for low level implementations . Also, these are the standards libs so they are well tested and efficient to use in your applications.