IE vs Firefox


Lately I was working on Javascript and I came across a problem that was just because of some difference in browsers.
What I was trying to do was, using Javascript I was creating HTML elements dynamically as per requirement and setting different attributes of these elements. While doing so I used setattribute function to set the attribute of the elements. It worked very fine on FF but It started giving problem on IE(sucking IE).

So I kept searching for many solutions to make it working on IE as well as FF.  As searching and getting a solution was a tough job, may be I was not very good at googling for it.. 😦

Let me first write the code that was working on FF but not IE:

ele = document.createElement('input'); //works on IE as well as FF
ele.setAttribute("type", "checkbox"); // works on IE as well as FF
ele.setAttribute("onclick", "myFunc(parameters);"); //Works only on FF
li.appendChild(ele); //li is my list element, appended the checkbox to it

The Code that worked for both is as under:(Solution)

ele = document.createElement('input'); //works on IE as well as FF
ele.setAttribute("type", "checkbox"); // works on IE as well as FF
ele.onclick = function{ myFunc(parameters);}; //Works for both FF & IE
li.appendChild(ele); //li is my list element, appended the checkbox to it

Cheers.. Hope I helped you.. 🙂

Mother Oh Mother..


I dedicate this poem to my mother.. Love you the most..
————
I was a just-born and she was Twenty-Five,
Though we were we, we were one.
I would cry out and she would respond in love always,
I would learn nothing but she never got tired to teach.

I was surrounded by monsters eager to pull my cheek,
but they would vanish the moment I was wet and weep.
She would come running and hold me in her arms,
as if I had won the contest of the charms.

Now I was able to walk and chew,
and hey, I was two.
I and she could now understand each other,
I was her everything and she needed no other.

I would try to walk and fall down,
But knowing she was with me,
the fear of getting hurt was now gone.
We still could not converse that effectively,
But she would understand my needs so easily.

I could now roam about free,
because now I have turned three.
I was ready to join a new world,
my academic life was now gonna mould.

She would dress me as best as a prince,
but when I would come back,
she would need at least an hour to rinse.
I was now able to talk,
I was a ferry and she was my dock.

I still remember the child, whose shirt I had tore,
Hey buddy, I have turned four.
I now came home a little late,
Nevertheless finding her waiting at the gate.
She would hug me and carry me in her arms,
it felt like flying through the farms.
We now did the homework together,
I would spoil the home and she used to work.

Years passed and now I was eighteen,
and with each year I would forget to lean.
I wouldn’t care for what she said,
because now I had become mean.
She would ask me to study for a good future,
but I was busy in a different culture.
Now I had many shes in my life,
I dreamed of having one of them as my wife.

I changed a lot which she did not teach,
She would try to hug me but I was out of reach.
She still waited for me at the gate,
but I would look at her with utmost hate.
She would be awake till late in the night,
because I wasn’t home, I was enjoying somewhere.
She had so much to scold, but she never did say,
hoping to find me better the next day.
Time went on and now I am grown,
lost in the world of my own.

I and she, between us have a river,
I have left her for my career.
When I was young, for me, she sacrificed her ambitions,
but I don’t care, I now have my own mission.
I am not with her now, I am in a different city,
she is so old now but I don’t even pity.

She needs me now but I am nowhere to find,
in the race for appraisal, I have become blind.
In a few years from now, I will be two,
there will be in my life someone new.
Then I’ll forget even to bother,
I am her son and she is my Mother
———————————

Nice rhyme and a good meaning. 😀

JDBC with mySQL


The purpose of this Post is to get you beyond the initial hurdles involved in:

  • Use mySQL database for use with JDBC.
  • Writing and testing your first JDBC programs to administer the database and to manipulate the data stored in the MySQL database.

* What is JDBC:

JDBC technology is an API (included in both J2SE and J2EE) that provides cross-DBMS connectivity to a wide range of SQL databases and access to other tabular data sources, such as spreadsheets or flat files.

*  Connecting Java and mySQL

For Connecting Java and mySQL database you will need a Connector called “MySQL Connector/J” :

Download the Connector

What is MySQL Connector/J?

For those who don’t know, let me begin by explaining the purpose of MySQL Connector/J.

The JDBC API is designed to make it possible for you to write a single Java program and to use it to manipulate the data in a variety of different SQL database servers without a requirement to modify and/or recompile the program.  In order to do this, it is necessary for you to:

  • Inform the Java program as to the URL of the database server.  You can accomplish this with input data when you start the program.
  • Provide the Java program with a programming interface to the specific database server that you intend to use.  Assuming that the programming interface has been installed on your computer, you can also accomplish this with input data when you run the program.
Installing MySQL Connector/J :  First Extract the Connector/J downloaded archive.

It consists of many files. The file which is most imp for us is the jar file. May be named as:   “mysql-connector-java-5.1.12-bin.jar”

5.1.12 is the version, can be different for you. Depends on the version of Connector you download.

Now to install the Connector you will have 2 methods:

1. The following statement appears in the connector documentation Section 2.2.1. entitled Setting the CLASSPATH

copy the “com” and “org” subdirectories and all of their contents to anywhere you like, and put the directory holding the “com” and “org” subdirectories in your classpath

2. Second Method:

put mysql-connector-java-[version]-bin.jar in your classpath, either by adding the FULL path to it to your CLASSPATH environment variable, or by copying the .jar file to $JAVA_HOME/jre/lib/ext.

I will like to tell you the best method that worked for me and which is most uncomplicated is: Copy the downloaded Connector .jar file into /java/jre/lib/ext    folder. This easier rather typing commands or setting the classpath for different .jar files you need to run you program.

Note:  bfore running java programs on Windows Command prompt just do the following 2 steps and you can run the program from any directoy.

  • set path= “path of jdk/bin folder”    (without quotes) the path may be like(for Windows users)

C:\Program Files\Java\jdk1.5.0_14\bin

  • set classpath=%classpath%;.;

3. Lets check the connectivity using the Java Code:

Consider here the following things in the code:

  • database_name= The database you have made in mySQL you have to use
  • Database_password= Password of “root” in mySQL, you are using mySQL database as a ‘root’
  • The table you are using is “person” which has columns “name” and “age”
  • In the following code you take the name of person as command-line argument and use it to run the query
  • The command line argument is name of person you have in your database 🙂
  • Steps to run the following java code:
  • Save the following code and name the file as “example.java”
  • Run command on command prompt (Compile the code):    javac example.java
  • Execute the compiled File (Hope there are no Errors):  java example argument  (for example:    java example aniket      )


//Import Packages

import java.sql.*;
import java.lang.*;
public class example{
Connection con = null;
Statement smnt;
ResultSet rs;
String querystring;
public static void main(String[] args){
try{
final String DRIVER,DATABASE,USER,PASS;
DRIVER="com.mysql.jdbc.Driver";
DATABASE="jdbc:mysql:///database_name";
USER="root";
PASS="Database_password";

Class.forName(DRIVER).newInstance();
con = DriverManager.getConnection(DATABASE,USER,PASS);
if(!con.isClosed()){
System.out.println("MySQL server connected...");
smnt= con.createStatement();
querystring= "select age from person where name=\"" + args[0] + "\"";
rs = smnt.executeQuery(querystring);
if(rs.next()){
System.out.println("The age is" + rs.getString("age"));
}
rs.close();
con.close();
}
}//try Block Ends here
catch(Exception e) {System.err.println("Exception: " + e.getMessage());}
}//main ends here
}//class Ends

So the code is as above..
Here the post ends.. Hope this works for you..
While writing this post, I considered that you have Java(JDK) and mySQL configured on your computer.
Else this will not work for you.
Cheers… 🙂

Lucid Lynx — Ubuntu 10.04


After Every six months(April and October), I am waiting for release of the .04 and .10 version of Ubuntu Systems. I am always eager to see the updates in the updated versions. And so,  here I am waiting for the April Version of Ubuntu 10.04, named asLucid Lynx“.

So Lets take a look on to what are the features in Lucid Lynx: The new style in Ubuntu is inspired by the idea of “Light“.

New Logos:

1. Gnome 3 though awaited to be there in the release. Lucid still has Gnome 2.x version used in it. So there will not be many changes in the look and UI part. It is of course to be expected that Gnome 3 will have a lot of rough edges at its birth, which again doesn’t make it ideal in a LST release.

The upcoming Gnome 3 that is to be released early 2010, can already be tested in an early stage in Ubuntu 9.10. If you want to test the Gnome Shell, install the package “gnome-shell“,

open a terminal and enter the command gnome-shell –replace&“.

2. More Fast Boot: After using Ubuntu 9.10, I am sure that the system boots extremely fast, takes very very little time.  And I suppose that 10.04 will also lead to the same experience. Boot speed has been a hot topic for a long time now and Ubuntu has come a long way in the last few releases. For Ubuntu 10.04 the target boot speed is 10 seconds! The reference platform for this target is a Dell Mini 9 netbook with a slow CPU and fast SSD that makes it an excellent “middle of the road” machine.  Some people’s machines will be slower, some will be faster.There’s also a plan to improve the speed on the installation process. Currently when installing packages in Ubuntu the download is a separate step from the unpack/configure. Ubuntu will be able to install package faster by doing downloads and installs in parallel. While downloading the cpu and disk are mostly idle. While installing the network is idle. Doing them in parallel is a good way to utilize both systems.
Under the hood Ubuntu 10.04 will also be switching to using a swap file, instead of a separate partition. This will allow on-the-fly resizing.

A graphical OS selector is planned for switching (rebooting) between two or more operative systems. The preferred version of the graphical OS selector will have easily recognizable logos for the installed OSs. This will require a lot of work and might not actually land in 10.04.

3. New Boot Splash :

Ubuntu Splash

4. Some other Features:

Mozilla FireFox: Default search engine has been changed to Yahoo! Default Home Page will use either Google or Yahoo! depending on user setting.

Linux Kernel: It includes the 2.6.32-14.20 kernel based on 2.6.32.8.

The likewise-open package, which provides Active Directory authentication and server support for Linux, has been updated to version 5.4. The package supports upgrades from both the officially supported versions 4.0 (Ubuntu 8.04 LTS) and 4.1 (Ubuntu 9.10), as well as the likewise-open5 packages from universe. Since this upgrade involves a lot of configuration file changes and in-place database upgrades, testing and feedback is appreciated.

SNS-> Go Social: Ubuntu now feature built in integration with Twitter, identi.ca, Facebook, and other social networks with theMeMenu in the panel, which is built upon the Gwibber project, which has a completely new, more reliable backend built on top of desktopcouch. Gwibber now also supports a multi-column view for monitoring multiple feeds simultaneously.

Ubuntu 10.04 Lucid Lynx

Ubuntu 10.04 Lucid Lynx

Ubuntu 10.04 will be out on 29th April, 2010

Want to know about Ubuntu More.

Cheers….

Helping those who need help 😀

Ubuntu gnome-panel


Just Updated my Ubuntu System to new kernel and also other security updates.
But after the update was applied and I restarted my system, all the gnome-panel icons were missing and the right hand corner of the panel where I have System Date, Network Icon, indicator-applet, all were missing.
So just in case you face the same problem here are some solutions which I have used.
Note: type the commands on terminal. 🙂
You can refresh the panel with:
Code:

killall gnome-panel &

If you want to return the panel to the default settings:
Code:

gconftool-2 –recursive-unset /apps/panel && killall gnome-panel &

“Gud Luck

Japanese On Linux (Ubuntu)


Hello Guyz. Recently I have been studyin Japanese language more than doing anything else in my life, last 7months.
On windows configuring language to be used is very easy, but to configure Japanese language on Linux was very tough, i dont knw why.
But finally I was able to enable typing in Japanese on my Ubuntu OS also.
And here are the links which helped me to configure the language support on my Linux system. I have used SCIM repositories to configure different language support on my computer. And also install Language support on the computer using System-> administration-> language support… 🙂

The links I have referred are :
1. SCIM Ubuntu Documentation
2. SCIM Anthy

I am sure these links will help you too.. 🙂
Feedback is invited.. 🙂