Tuesday, November 14, 2006

Want to sing...

Ah ha! So finally after a long time I got something interesting to do...

    I remember last time when I started RnD work on decoding MP3 file...uff!!! that was so frustating. I banged my head for around 5 days continously, but all in vain, except that I learn to read at least ID3 Tag Information. Atleast I got something...

    I have been to mumbai last weekend, the trip was awesome, enjoyed a lot. Tonnes of thanks to my fosla friends in Mumbai and Gyanu. There I came across an article on Ogg Vorbis another audio file format equivalent to MP3 files. The most interesting thing is that it is open source where as MP3 is patented that means you have to pay but this one is totally free for both commercial and non-commercial use. The compression ratio is also high. Good naaa ;-)

    Hope my code will sing this format. :-)

Friday, October 06, 2006

Pool connection

Here is a quick way to make a connection pool...
  1. Get the jar file, that will be specific to the database to which you want to connect and place it in the /WEB-INF/lib folder.

  2. And edit /META-INF/context.xml...
    <Context reloadable="true">
    ....
    <Resource
    name = "jdbc/dbtest"
    auth = "Container"
    type = "javax.sql.DataSource"
    factory = "org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
    driverClassName = "org.postgresql.Driver"
    url = "jdbc:postgresql://IPAddress:port/databasename"
    username = "root"
    password = "root"
    maxActive = "5"
    initialSize = "3"
    maxIdle = "2"
    maxWait = "10000"
    removeAbandoned = "true"
    removeAbandonedTimeout = "60"
    logAbandoned = "true"
    />
    ....
    </Context>

  3. Java code to get connection from the pool...
    InitialContext initCtx = new InitialContext();
    Context ctx = (Context) initCtx.lookup("java:comp/env");
    DataSource ds = (DataSource) ctx.lookup("jdbc/dbtest");
    conn = ds.getConnection();
That's it. Start the tomcat server and launch the application...
Here are the details of the attributes used in xml file.
  1. Name: The java:comp/env prefix is the name of the JNDI context for the component. This is used in the Java code. The jdbc/dbtest string is the JNDI name for the resource reference. The JNDI names for JDBC DataSource objects are stored in the java:comp/env/jdbc subcontext.

  2. auth: Authration will be done by container. I don't know much about this. Will update soon.

  3. driverClassName: Fully qualified Java class name of the JDBC driver to be used.

  4. url: Connection URL to be passed to JDBC driver.

  5. username: Database login username.

  6. password: Database login password.

  7. maxActive: (Default: 8) The maximum number of active instances that can be allocated from this pool at the same time.

  8. maxIdle: (Default: 8) The maximum number of connections that can sit idle in this pool at the same time.

  9. maxWait: (Deafult: indefinitely) The maximum number of milliseconds that the pool will wait (when there are no available connections) for a connection to be returned before throwing an exception.

  10. initialSize: (Default: 0) The initial size of the pool.

  11. removeAbandoned: (Default: false) Flag to remove abandoned connections if they exceed the removeAbandonedTimout. If set to true a connection is considered abandoned and eligible for removal if it has been idle longer than the removeAbandonedTimeout. Setting this to true can recover db connections from poorly written applications which fail to close a connection.

  12. removeAbandonedTimeout: (Default 300) Timeout in seconds before an abandoned connection can be removed.

  13. logAbandoned: (Default: false) Flag to log stack traces for application code which abandoned a Statement or Connection.


Note: For more details check commons-dbcp documentation.
Thanks
E ñ j Ô ÿ !!! iN D
p
0 o l
:-)

Monday, September 18, 2006

Enabling SSL in Tomcat

I have done this in windows, didn’t tried this on Linux machine.
Its easy and simple, just follow these steps:

  1. First we will need to generate a keystore file, containing a self-signed certificate. Execute the following command on the prompt

    %JAVA_HOME%\bin\keytool -genkey -alias tomcat -keyalg RSA

  2. Open file <tomcat-home-dir>\conf\server.xml.
  3. Find and uncomment the following code:

    <Connector port="8443"
    maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
    enableLookups="false" disableUploadTimeout="true"
    acceptCount="100" debug="0" scheme="https" secure="true"
    clientAuth="false" sslProtocol="SSL" />

  4. Change the value of the port if you need.
  5. In this clientAuth is set to false. Change its value to true if you want client authentication. In this case if client authentication fails then it won’t let you to proceed. Set it then it to want if you you want to proceed even if authentication fails.
  6. If the sslProtocol is set to TLS then set it to SSL. TLS is an IBM’s implementation and is not compatible with some browsers.
  7. Now try opening https://localhost:8443. It should display the tomcat’s home page. If it is not installed, try running some other application that you have deployed with https.

For more details you can view the SSL documentation that comes with the tomcat on your local machine or you can logon to the website http://localhost:8080/tomcat-docs/ssl-howto.html.


E ñ j Ô ÿ !!!

Monday, May 22, 2006

I never did this before...

Yes, I have never done this before....

March In Protest Rally !!!

It was 21st of May 2006, I wake up late around 0900 Hrs, and I was ready after having bath. I was hungry, and just getting ready to go out to have breakfast, and my phone ranged. That was a missed call from Swati. The clock was 0945Hrs.
I thought came to my mind, this girl will not gonna stop, she will definitely join rally. I reached at om at 1000 Hrs. The sun was shining high up in the sky and it was bit hot. My friends were waiting for all to gather. I was not expecting from them, that they will gonna join rally. At around 1020 Hrs we left for Pune University, from where the rally is going to start.
When we reached there were around 150-200 protestors and police.
Suddenly a FOSLA comment came "Ye rally Policewale nikal rahe hain ki students, kyunki yahan students se jyada to policewale hain". We started laughing...
The rally started at around 1120 Hrs. We came to know that this is a peace rally; you cannot shout slogans and all. For next 15-20 minutes we were clapping. Then suddenly at the back people started shouting slogans. And all get energized. Now once it started, who could stop easily. Then the students who were leading/managing the rally asked them not shout slogans. In between the rally we got chart papers and sketch, and we also raised our banners. Then as the rally proceeds, some more people joined the rally. And rally peacefully moves forward with shouting slogans/singing song Hum honge kamiyaab ek din... and Oye hoye tune... of Rang De Basanti after every 5-10 minutes. The rally is about to reach it's destination i.e. corporation, we passes by Congress Bhavan. Energy level of crowd was at the peak at that time. Each and everyone was shouting and showing banners to people working there at that time.
I really enjoyed that...because I never did that before.
After that within 5 minutes we reached at corporation gate and dispersed.
It was 1330 Hrs and we were really exhausted and hungry and came had our lunch at Delhi Kitchen. After 5 minutes Swati, Vishal and Jassi came. They were in a mood to join the second rally that was from SNDT College to Sambhaji Park.
I was exhausted, but after lunch I told them that I would also join. But that was supposed to start at 1600 Hrs. Then we went to Vishal's place to take rest.
Now I was totally new company, except Swati. Vishal and Jassi were almost new to me.
After sometime one of their friend Pallavi came , sweet and simple girl, she was going for her SCDL exam. She was not feeling well because of stone problem. So Jassi went with her to the college, but after some they both came back, as she was having severe pain.
After sometime their roommate Anurag also came at room. Jassi was saying some or the other thing to Anurag and we all were laughing. He was after him like anything.
It was around 1600 Hrs, and Swati started forcing Vishal and me to join rally. But Vishal and I were really tired. And we started acting that we don't have to go. But she didn’t stop, finally at 1630 Hrs we left Vishal's place, had tea and we were at SNDT college in 15 minutes.
When we reached there, we were happy after looking at the strength. There were around 800-1000 students.
The rally started at around 1700 Hrs. And we joined, this one was really a peaceful rally, no slogans nothing. We just marched to the Sambhaji Park. After that we were asked to disperse. Then we rest at the bench in Sambhaji Park only, had bhel, then milkshakes at FC Road. It was around 1930 Hrs, when we thought that we should take dinner and then go home. Then Swati and Jassi called Anurag and Jassi for dinner plan. After 15-20 minutes we were at Vishal's place as there was no plan.
Pallavi was not fine, but she was feeling better after taking pills. And Jassi was again in action with his naughty face.
We had dinner around 2030 Hrs and after that icecream. And we were back to home after some chat.

Huh!!! On this day I really squeezed out my energy.

Lets see what happens to this quota !

Tuesday, April 25, 2006

Another Boring Day

It's end of April, and I joined this company in January as a trainee.
We got assignments in our traning, that we have finished in 2.5 months.
After that we have nothing to do here. I never had this much chatting and e-mailing. Well this lasted for 4-5 days, and after that I am back on my schedule i.e. turn on music and start RnD.

Finally we got project in mid April.
We were really excited.
We kicked off our project with database designing and after that we all got modules to code.

I got the searching part; I did that in four days with the required code reusability and other requirements.

Now, from the last Friday we are waiting for the design team to complete their job.

And as our Project Manager has given the spec. that is indicating that we might have to change our code.

So I am still searching for some interesting topic on which I can do some RnD.

Anyways, let's see what will gonna happen...
as who knows what life will gonna bring next....

Saturday, April 22, 2006

Humm....

So finally I have cretead a blog.
Now It comes to management...

Lets see how well I can manage this.