<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8181692097334192490</id><updated>2012-01-15T00:28:08.305-08:00</updated><category term='I thought'/><category term='Java API'/><category term='hack'/><category term='MySQL'/><category term='C'/><category term='Sql Server'/><category term='Java Quirks'/><category term='glassfish'/><category term='jsp'/><category term='Syntax Highlighter'/><category term='selenium'/><category term='Blogger'/><category term='Java'/><category term='form'/><category term='Testing'/><category term='firefox'/><category term='Tomcat'/><category term='TDD'/><category term='Hosting'/><category term='Database'/><category term='spring'/><category term='browser'/><category term='ODBC'/><category term='bean'/><category term='Automation'/><category term='Quartz'/><title type='text'>avaJ dnoyeB efiL</title><subtitle type='html'>Some#random('thoughts'); //technical, non technical</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>20</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-1752320964925666050</id><published>2011-12-07T23:22:00.000-08:00</published><updated>2011-12-14T08:38:37.631-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Testing'/><category scheme='http://www.blogger.com/atom/ns#' term='TDD'/><title type='text'>PIT Tests, a Mutation Testing</title><content type='html'>&lt;p&gt;While wondering over internet, I just come across the "mutation testing" and here I blog about it. The blog largely said about one such framework "&lt;a href="http://pitest.org/"&gt;PIT tests&lt;/a&gt;".&lt;/p&gt;&lt;p&gt;When we say my code coverage is 80%, that only mean, in simple term, your unit tests cover 80% of your code base. Do they really tell you what your tests are really testing? -  No.To answer this, there is a thing that called as "mutation testing". The framework I am talking about is PIT tests; they said it’s like automation tests for your tests. Cool!&lt;/p&gt;&lt;p&gt;How does it work?&lt;/p&gt;&lt;p&gt;Well in plain simple language, it mutate (modify the byte code at runtime) some logical part, decision taking part of your code and then run tests against such modified code, if your test fail (called as mutation killed), your test is OK, if its passed (called mutation survived), beware, there might be some bug hidden there. So, more the mutation killed more good your tests are.&lt;/p&gt;&lt;p&gt;Example:&lt;/p&gt;&lt;p&gt;The simplest example might be,&lt;pre name="code" class="java"&gt;&lt;br /&gt;if ( i &amp;lt; 5)&lt;br /&gt;   return "hi";&lt;br /&gt;else &lt;br /&gt;   return "bye";&lt;br /&gt;&lt;/pre&gt;Consider you write tests for it, and all are passing. Now, when pit tests executes over such tests, they mutated to this runtime as&lt;pre name="code" class="java"&gt;&lt;br /&gt;if ( i &amp;lt; 5) // operator &amp;lt; mutate to &amp;lt;=&lt;br /&gt;    return "hi";&lt;br /&gt;else &lt;br /&gt;    return "bye";&lt;br /&gt;&lt;/pre&gt;And tests are rerun over such mutated code, if you really test such methods for boundary condition; everything will be good otherwise bug will occurs.&lt;/p&gt;&lt;p&gt;There is few &lt;a href="http://pitest.org/quickstart/mutators/"&gt;default mutators&lt;/a&gt; that are applied while mutation testing using PIT.&lt;/p&gt;&lt;p&gt;That’s all, give it a try and see if its suits in your organization culture ;).&lt;/p&gt;  &lt;p&gt;What’s missing?&lt;/p&gt;&lt;p&gt;Only thing I felt that need to improve for PIT tests are the HTML report visibility, the report doesn’t clearly states how many test got the problem, means how many tests are killed and how many are survived. I think this info should be aggregated on index page.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-1752320964925666050?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/1752320964925666050/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=1752320964925666050' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/1752320964925666050'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/1752320964925666050'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2011/12/pit-tests-mutation-testing.html' title='PIT Tests, a Mutation Testing'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-2451211646469599267</id><published>2011-10-08T22:55:00.000-07:00</published><updated>2012-01-15T00:23:49.360-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Testing'/><category scheme='http://www.blogger.com/atom/ns#' term='Automation'/><title type='text'>Not 10, but 6 things about jMeter</title><content type='html'>I list down some "good to know" things about jMeter. Hope it helps you while considering the jMeter scripts design, development and execution.&lt;br /&gt;&lt;div class="MsoListParagraphCxSpFirst" style="mso-list: l0 level1 lfo1; text-indent: -.25in;"&gt;&lt;/div&gt;&lt;ol&gt;&lt;li&gt;&lt;span style="font: normal normal normal 7pt/normal 'Times New Roman';"&gt;&amp;nbsp;&lt;/span&gt;Its open source Java tool for functional andload testing.&lt;/li&gt;&lt;li&gt;Can be "extended" to create newsampler, controller etc.&lt;/li&gt;&lt;li&gt;Module Controller - If your scripts are goingheavy and you found many copy-paste steps; in that case just create a module ofthose steps. Module is like a function in programming.&lt;/li&gt;&lt;li&gt;Include controller - Some modules are global andcan be used in many scripts, in that case just include that JMX into your mainJMX, like you include JSP tag.&lt;/li&gt;&lt;li&gt;Parameterized Controller - Third partycontroller which enable us to pass various runtime parameters to sample.Usually sits on top of module controller.&lt;a href="http://code.google.com/p/jmeter-plugins/"&gt;http://code.google.com/p/jmeter-plugins/&lt;/a&gt;&lt;/li&gt;&lt;li&gt;jMeter scripts can be executed from ANT, it helpin automating the daily execution of scripts. (Can be triggered from nightlybuild process from your CI server):&lt;a href="http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php"&gt;http://www.programmerplanet.org/pages/projects/jmeter-ant-task.php&lt;/a&gt; The samesite also got one XSLT for transforming your JTL (jMeter log of sriptexecution) to HTML report.&amp;nbsp;&lt;/li&gt;&lt;/ol&gt;I''ll update this list as I&amp;nbsp;explore&amp;nbsp;jMeter more!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-2451211646469599267?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/2451211646469599267/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=2451211646469599267' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/2451211646469599267'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/2451211646469599267'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2011/10/10-6-things-about-jmeter.html' title='Not 10, but 6 things about jMeter'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-3905575186159711711</id><published>2011-06-04T01:02:00.000-07:00</published><updated>2012-01-15T00:21:50.732-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='spring'/><title type='text'>VM arguments in spring context</title><content type='html'>In case you trying to access the VM arguments in spring application context,  then just add the below bean definition in context file:&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&amp;gt;&lt;br /&gt;      &amp;lt;property name="ignoreUnresolvablePlaceholders" value="true"&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And access the VM args as ${vm_property}, e.g if you passed the –Dfoo=bar, which can be access as,&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;bean class="com.company.test.MyClazz"&amp;gt;&lt;br /&gt;      &amp;lt;property name="myProperty" value="${foo}"&amp;gt;&amp;lt;/property&amp;gt;&lt;br /&gt;&amp;lt;/bean&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-3905575186159711711?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/3905575186159711711/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=3905575186159711711' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/3905575186159711711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/3905575186159711711'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2011/06/vm-arguments-in-spring-context.html' title='VM arguments in spring context'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-172988487477879057</id><published>2011-04-08T08:23:00.000-07:00</published><updated>2011-04-08T08:23:29.583-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='firefox'/><category scheme='http://www.blogger.com/atom/ns#' term='selenium'/><category scheme='http://www.blogger.com/atom/ns#' term='hack'/><category scheme='http://www.blogger.com/atom/ns#' term='browser'/><title type='text'>Quick Fix: Selenium + FireFox 4</title><content type='html'>Being a firefox fan, I just updated my current FF (3.6.x) to FF 4, everything goes well and I could see much improved FF both performance and UI wise, but I couldn't use selenium IDE with it (Yes, some time I do UI testing), so after some googling found 2 solutions:&lt;br /&gt;&lt;br /&gt;Solution #1: If you already have the selenium installed but its disabled because it's not supported by FF 4 yet, the fix (hack) is explained &lt;a href="http://groups.google.com/group/selenium-users/browse_thread/thread/c7a225f0b0ec7670"&gt;here&lt;/a&gt; (See Mark Collin reply)&lt;br /&gt;&lt;br /&gt;Solution #2: If you don't have selenium IDE installed, then simply download the latest supported but not yet released selenium IDE installer from &lt;a href="http://groups.google.com/group/selenium-users/browse_thread/thread/c7a225f0b0ec7670"&gt;here&lt;/a&gt; and install it just by dragging or opening it to FF window.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-172988487477879057?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/172988487477879057/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=172988487477879057' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/172988487477879057'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/172988487477879057'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2011/04/quick-fix-selenium-firefox-4.html' title='Quick Fix: Selenium + FireFox 4'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-6625736647231915444</id><published>2011-03-13T00:07:00.000-08:00</published><updated>2011-04-10T00:22:19.846-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='TDD'/><title type='text'>What I've learned from TDD</title><content type='html'>TDD, I'm practicing development using unit test from 1 year now and frankly speaking I'm loving it. I listed some points/notes/importance I learned from TDD. You might like to add some points or want to correct me, so please comment.&lt;br /&gt;&lt;br /&gt;Here the list goes:&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Caught 80% of bugs at first place before your code goes to production.&lt;/li&gt;&lt;li&gt;Explore and forces to think the development and design in proper Object Oriented way, means less class dependencies, loose coupling's, SRP etc.&lt;/li&gt;&lt;li&gt;You can fearlessly do refactoring and enhance the quality of existing code if you have enough unit test code surrounding. &lt;/li&gt;&lt;li&gt;If you have been reported any bug/issue in production code, write the unit test that produce that bug and fail(red), then fix the code(refactor) and ultimately make the unit test to success( green).&lt;/li&gt;&lt;li&gt;Gives idea about the usage of API you're developing.&lt;/li&gt;&lt;/ol&gt;I know this are not the only points which make TDD incredibly great practice, but I'll update this blog for some more points as they come along into my practices.&lt;br /&gt;&lt;br /&gt;Updates: Some TDD Quaote.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Whenever you are tempted to type something in a print statement or a debugger expression, write it as a test. - Martin Fowler&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-6625736647231915444?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/6625736647231915444/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=6625736647231915444' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/6625736647231915444'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/6625736647231915444'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2011/03/what-ive-learned-from-tdd.html' title='What I&apos;ve learned from TDD'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-3318821094701285389</id><published>2010-08-07T06:17:00.000-07:00</published><updated>2011-01-16T06:18:38.783-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='glassfish'/><title type='text'>GlassFish V3 admin console taking too much time to load.</title><content type='html'>If you have installed Glassfish V3 and trying to load admin console, but after signing in, is it taking too much time to get to the main page ? Do you have server.log entry like this:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;admin console: initSessionAttributes()&lt;br /&gt;Cannot refresh Catalog : Connection timed out&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;then its time to tweak some files. Here its how:&lt;br /&gt;&lt;br /&gt;1. Update the %GLASSFISH_HOME/glassfish/domains/domain1/domain.xml&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;java-config&gt; &lt;br /&gt;     &lt;jvm-options&gt;-Dcom.sun.enterprise.tools.admingui.NO_NETWORK=true&lt;/jvm-options&gt;   &lt;br /&gt;&lt;/java-config&gt; &lt;br /&gt;&lt;/pre&gt;This will block up the News item, the registration item, etc&lt;br /&gt;&lt;br /&gt;2. Remove update tool jar&lt;br /&gt;(Backup and remove this JAR)&lt;br /&gt;&lt;blockquote&gt;%GLASSFISH_HOME/glassfish/modules/console-updatecenter-plugin.jar&lt;/blockquote&gt;Delete this dir:&lt;br /&gt;&lt;blockquote&gt;%GLASSFISH_HOME/glassfish/domains/domain1/osgi-cache&lt;/blockquote&gt;&lt;blockquote&gt;%GLASSFISH_HOME/glassfish/domains/domain1/generated&lt;/blockquote&gt;&lt;br /&gt;Now start the server (bin/asadmin start-domain) and you will see the admin console won't be hang up and take you directly to main page.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-3318821094701285389?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/3318821094701285389/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=3318821094701285389' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/3318821094701285389'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/3318821094701285389'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2010/08/glassfish-v3-admin-console-taking-too.html' title='GlassFish V3 admin console taking too much time to load.'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-7876042585441037408</id><published>2010-06-02T07:26:00.000-07:00</published><updated>2011-07-21T06:19:08.340-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Read file outside the JAR</title><content type='html'>Hi All, I’m back from loooong vacation. Actually haven’t done anything great to blog about, only update is, I switched the company…&lt;br /&gt;&lt;br /&gt;Here is recent Java trick I found and I think I should share it..&lt;br /&gt;Problem: I’m wondering about how can I read the file which is in the same directory of my executable JAR ?&lt;br /&gt;[Edited: Read the comment to get easy and obvious answer :)]&lt;br /&gt;Solution:  Its simple, just get the current directory and append the file you want to access whose path is relevant to the JAR. Like&lt;br /&gt;&lt;code&gt;&lt;br /&gt;/mydir/Myjar.jar&lt;br /&gt;/mydir/my.properties&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;In order to read the “my.properties”,   I just used the following code.&lt;br /&gt;&lt;pre name="code" class="java"&gt;FileReader reader = new FileReader(new File(new File(“.”),   “my.properties”));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Simple.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-7876042585441037408?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/7876042585441037408/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=7876042585441037408' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/7876042585441037408'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/7876042585441037408'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2010/06/hi-all-im-back-from-loooong-vacation.html' title='Read file outside the JAR'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-1675915806537681399</id><published>2009-11-20T09:21:00.000-08:00</published><updated>2009-12-27T23:14:28.213-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java API'/><title type='text'>Easy Start  with JNA</title><content type='html'>JNA (Java Native Access) is the good and easy answer to the JNI(Java Native Interface). Those who find it cumbersome to to call C, C++ DLL functions using JNI, then JNA is for you. The project is hosted at &lt;a href="https://jna.dev.java.net/"&gt;https://jna.dev.java.net/&lt;/a&gt; .&lt;br /&gt;&lt;br /&gt;Here is my first encounter(experiment) with the JNA.&lt;br /&gt;&lt;br /&gt;Problem: I want to call one DLL function in Java program&lt;br /&gt;&lt;br /&gt;Solution: The first thing that comes into my mind is JNI, coz I heard a lot about it whenever something "native" has to be called in Java. Just while surfing for the more information on basic JNI programming, I came across the JNA project/api and find it interesting to give it try.&lt;br /&gt;&lt;br /&gt;Here are the basic two things you need to have in order to use JNA&lt;br /&gt;1) JNA api JAR file (jna.jar):&lt;br /&gt;&lt;blockquote&gt;Download it from &lt;a href="https://jna.dev.java.net/source/browse/*checkout*/jna/trunk/jnalib/dist/jna.jar?rev=HEAD"&gt;here&lt;/a&gt;&lt;/blockquote&gt;&lt;br /&gt;2) DLL which you want to call in your Java program&lt;br /&gt;&lt;blockquote&gt;Now this may be the big thing for a guy who haven't worked on VC++, DLL, MFC etc things. So here is the quick link about how to create the DLL&lt;br /&gt;http://www.icynorth.com/development/createdlltutorial.html&lt;/blockquote&gt;&lt;br /&gt;This is the best about JNA, you don't need to write header file as that we need to do in JNI&lt;br /&gt;&lt;br /&gt;JAVA Code&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;import com.sun.jna.*;&lt;br /&gt;import com.sun.jna.ptr.*;&lt;br /&gt;/** Simple example of JNA interface mapping and usage. */&lt;br /&gt;public class HelloWorld {&lt;br /&gt;    // This is the standard, stable way of mapping, which supports extensive&lt;br /&gt;    // customization and mapping of Java to native types.&lt;br /&gt;    public interface TestLibrary extends Library {&lt;br /&gt;        TestLibrary INSTANCE = (TestLibrary)&lt;br /&gt;            Native.loadLibrary("TestDLL", TestLibrary.class);&lt;br /&gt;                    // Call C/c++ function&lt;br /&gt;      void helloWorld(int n);   &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public static void main(String[] args) {&lt;br /&gt;        int n = TestLibrary.INSTANCE.helloWorld(1);        &lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;C/C++ Code&lt;br /&gt;&lt;pre name="code" class="c"&gt;&lt;br /&gt;extern "C" __declspec(dllexport) int helloWorld (int divider)&lt;br /&gt;{&lt;br /&gt;    return 77/divider;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-1675915806537681399?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/1675915806537681399/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=1675915806537681399' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/1675915806537681399'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/1675915806537681399'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2009/11/easy-strat-with-jna.html' title='Easy Start  with JNA'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-1726697320043395691</id><published>2009-08-24T09:51:00.000-07:00</published><updated>2012-01-15T00:19:04.132-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='bean'/><category scheme='http://www.blogger.com/atom/ns#' term='jsp'/><category scheme='http://www.blogger.com/atom/ns#' term='form'/><title type='text'>How to know when FORM (bean) values changed by user or not</title><content type='html'>Many times, developer want to know whether user has changed the HTML FORM value or values so that at server side action they can take the necessary action if some values has been changed or not changed at all. For example, once someone has requirement regarding whether user changed the IP address fields in the UPDATE HTML FORM, because if that value has been changed by the user, then he need to make several heavy network calls, which he wants to avoid if user doesn't change that single value. Also, recently someone wants to know if the FORM has changed by single value or submitted as it without any change.&lt;br /&gt;&lt;br /&gt;For this above scenario, there are two (best) possible solutions:&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;1. If you want to observe the value change for particular bean property, then use dummy variable in bean and if you do not wish to create one, then pass the previous bean value in query string.&lt;/blockquote&gt;&lt;br /&gt;How to make it:&lt;br /&gt;&lt;pre class="java" name="code"&gt;public class MyForm&lt;br /&gt;{ &lt;br /&gt;    private String name;&lt;br /&gt;    private Integer number;&lt;br /&gt;    // I like to know if this 'number' value was changed or not &lt;br /&gt;    // Crete a dummy variable for this "number"&lt;br /&gt;    private Integer number_;&lt;br /&gt;    /////////////////////////////&lt;br /&gt;    public String getName() {&lt;br /&gt;        return name;&lt;br /&gt;    }&lt;br /&gt;     public void setName(String string) {&lt;br /&gt;        name = string;&lt;br /&gt;    }&lt;br /&gt;    public Integer getNumber() {&lt;br /&gt;        return number;&lt;br /&gt;    }&lt;br /&gt;    public void setNumber(Integer i) {&lt;br /&gt;        number = i;&lt;br /&gt;    }  &lt;br /&gt;    // Getter and setter for number_&lt;br /&gt;    public Integer getNumber_() {&lt;br /&gt;        return number;&lt;br /&gt;    }&lt;br /&gt;    public void setNumber_(Integer i) {&lt;br /&gt;        number = i;&lt;br /&gt;    }   &lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;OR&lt;br /&gt;&lt;br /&gt;If you don't wanna create extra dummy variable, pass value as query string.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;!-- pass the number value as query string to the action --&amp;gt;&lt;br /&gt;&amp;lt;form action="/MyAction.do?number=${requestScope.number}&amp;gt;&lt;br /&gt;        Name:   &amp;lt;input type="text" name="name"/&amp;gt;&lt;br /&gt;        Number: &amp;lt;input type="text" name="number"/&amp;gt;&lt;br /&gt;                &amp;lt;input type="submit" value="Submit"/&amp;gt;&lt;br /&gt;&amp;lt;/form&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The action path will be:&lt;br /&gt;&lt;span style="font-style: italic;"&gt;/MyAction.do?number=123&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;2. If you're not concerned about any particular value change but like to know whether form values are different than the previously shown values, then use Object#hashCode();&lt;/blockquote&gt;&lt;br /&gt;How to make it:&lt;br /&gt;&lt;pre class="java" name="code"&gt;public class MyForm&lt;br /&gt;{ &lt;br /&gt;    private String name;&lt;br /&gt;    private Integer number;&lt;br /&gt;    /////////////////////////////&lt;br /&gt;    public String getName() {&lt;br /&gt;        return name;&lt;br /&gt;    }&lt;br /&gt;     public void setName(String string) {&lt;br /&gt;        name = string;&lt;br /&gt;    }&lt;br /&gt;    public Integer getNumber() {&lt;br /&gt;        return number;&lt;br /&gt;    }&lt;br /&gt;    public void setNumber(Integer i) {&lt;br /&gt;        number = i;&lt;br /&gt;    }&lt;br /&gt;    @Override&lt;br /&gt;    /**&lt;br /&gt;    * This is my logic for getting unique hashcode or you can implement you own&lt;br /&gt;    */&lt;br /&gt;    public int hashCode() {&lt;br /&gt;       String hashCode =  name.hashCode() + "" + number.hashCode();&lt;br /&gt;       return hashCode.hashCode();&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;You have to pass the populated beans hashcode to the action class and compare it with the current bean instance; If they are same then it mean the bean values are unchanged…&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-1726697320043395691?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/1726697320043395691/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=1726697320043395691' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/1726697320043395691'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/1726697320043395691'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2009/08/how-to-know-when-form-bean-values.html' title='How to know when FORM (bean) values changed by user or not'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-2373155982590080365</id><published>2009-07-09T06:27:00.000-07:00</published><updated>2009-08-09T07:21:07.390-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Blogger'/><category scheme='http://www.blogger.com/atom/ns#' term='Syntax Highlighter'/><title type='text'>Syntax Highlighter for Blogger</title><content type='html'>Update: Here is the simple two steps which will add "Syntax Highlighter" widget for blogger hosted blogs &lt;br /&gt;&lt;br /&gt;1. Go to : &lt;a href="http://fazibear.googlepages.com/blogger.html" target="_blank"&gt;http://fazibear.googlepages.com/blogger.html&lt;/a&gt;&lt;br /&gt;2. And click to : &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://www.blogger.com/img/add/add2blogger_sm_b.gif"&gt;&lt;img style="cursor:pointer; cursor:hand;width: 104px; height: 17px;" src="http://www.blogger.com/img/add/add2blogger_sm_b.gif" border="0" alt="" /&gt;&lt;/a&gt;&lt;br /&gt;---------------------------------------------------------------------------------------&lt;br /&gt;Today, one of my JR mate asked me about How did I add that syntax highlighter code in blogger ? OK, I knew I installed it from some blog, but not remembering the name of that site, so I googled it and all the hits shows me the way to install it using CSS defined and uploaded at googlepages site.&lt;br /&gt;Here is the code project site for same from Google:&lt;br /&gt;&lt;a href="http://code.google.com/p/syntaxhighlighter/" target="_blank"&gt;http://code.google.com/p/syntaxhighlighter/&lt;/a&gt; &lt;br /&gt;&lt;br /&gt;I tried this too, but with little success. Its not that easy.&lt;br /&gt;&lt;br /&gt;But, finally I found that blog and thus that post where author created the Blogger widget for syntax highlighter. Just add it and you can add code snippet in you blog.&lt;br /&gt;&lt;br /&gt;Here is that useful link:&lt;br /&gt;&lt;a href="http://fazibear.blogspot.com/2007/09/blogger-syntax-higlighter.html" taget="_blank"&gt;http://fazibear.blogspot.com/2007/09/blogger-syntax-higlighter.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-2373155982590080365?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/2373155982590080365/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=2373155982590080365' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/2373155982590080365'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/2373155982590080365'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2009/07/syntax-highlighter-for-blogger.html' title='Syntax Highlighter for Blogger'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-2312886990629169301</id><published>2009-05-12T12:32:00.000-07:00</published><updated>2009-05-13T03:35:23.865-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>INTO OUTFILE query, How to modify &amp; output null values ?</title><content type='html'>I tried one query (originally asked at JR) on MySQL which export the table data into a file, with a comma delimited field. The query is straight forward and replace the null column value by "\N" character, but when I want to replace that "\N" value by some other character like "0" or simple empty field like " ", its gets little tricky.&lt;br /&gt;&lt;br /&gt;Here is the base query &lt;br /&gt;&lt;pre name="code" class="sql"&gt;&lt;br /&gt;SELECT Id, name, age FROM student INTO OUTFILE 'c:/result.txt'&lt;br /&gt;FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'&lt;br /&gt;LINES TERMINATED BY '\n';&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And it outputs like, &lt;br /&gt;&lt;br /&gt;1, "sagar", 23&lt;br /&gt;2, "anant", 24&lt;br /&gt;&lt;br /&gt;Now suppose some 'name' fields are null, then it outputs like&lt;br /&gt;&lt;br /&gt;1, "sagar", 23&lt;br /&gt;2, \N, 24&lt;br /&gt;&lt;br /&gt;Now to obtain my desired results, which &lt;span style="font-style:italic;"&gt;replace &lt;/span&gt;this null (\N) values by empty string like, "", I tried out two solutions&lt;br /&gt;&lt;pre name="code" class="sql"&gt;&lt;br /&gt;--1.  Using CASE statement&lt;br /&gt;SELECT Id, &lt;br /&gt;CASE WHEN name IS NULL THEN '' &lt;br /&gt;ELSE name&lt;br /&gt;END AS NewName, &lt;br /&gt;age&lt;br /&gt;FROM student&lt;br /&gt;INTO OUTFILE 'c:/result.txt'&lt;br /&gt;FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'&lt;br /&gt;LINES TERMINATED BY '\n'; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;OR(By JR mate)&lt;br /&gt;&lt;pre name="code" class="sql"&gt;&lt;br /&gt;--2. Using 'ifnull()' function.&lt;br /&gt;SELECT Id, ifnull(name, '') as NewName, age from student;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;And either of this query gets you the following output into a file&lt;br /&gt;&lt;br /&gt;1, "sagar", 23&lt;br /&gt;2, "", 24&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-2312886990629169301?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/2312886990629169301/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=2312886990629169301' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/2312886990629169301'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/2312886990629169301'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2009/04/into-outfile-query-how-to-modify-output.html' title='INTO OUTFILE query, How to modify &amp; output null values ?'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-6812620521497424418</id><published>2009-04-13T00:21:00.000-07:00</published><updated>2011-01-13T07:21:21.653-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java Quirks'/><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><title type='text'>Java Generics: Why I get "name clash" exception when I override methods with different "type" parameter ?</title><content type='html'>&lt;pre name="code" class="java"&gt;import java.util.*;&lt;br /&gt;class Parent {&lt;br /&gt;void foo(List&amp;lt;String&gt; list) {&lt;br /&gt;System.out.println("parent");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;class Child extends Parent {&lt;br /&gt;void foo(List&amp;lt;Integer&gt; list) {&lt;br /&gt;System.out.println("child");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;When you compile this code you will get an error like&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;Parent.java:7: name clash: foo(java.util.List&amp;lt;java.lang.Integer&gt;) in Child and foo(java.util.List&amp;lt;java.lang.String&gt;) in&lt;br /&gt;Parent have the same erasure, yet neither overrides the other&lt;br /&gt;class Child extends Parent {&lt;br /&gt;^&lt;br /&gt;1 error&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;This "name clash" error thrown because of "type erasure" thing when "generics" code gets complied.&lt;br /&gt;Let’s see how, &lt;br /&gt;When we complied any generics code, the compiler removes the type from the code and treat it as a simple pre Java 1.5 code, like, in our case, compiler saw something like this, &lt;br /&gt;&lt;pre name="code" class="java"&gt;import java.util.*;&lt;br /&gt;class Parent {&lt;br /&gt;void foo(List list) { // oops, &amp;lt;String&gt; get erased.&lt;br /&gt;System.out.println("parent");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;class Child extends Parent {&lt;br /&gt;void foo(List list) { // same here&lt;br /&gt;System.out.println("child");&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And all this is because of "Type Erasure", and that’s forced compiler to think Child's method "foo" as a &lt;span style="font-weight:bold;"&gt;&lt;span style="font-style:italic;"&gt;overloading&lt;/span&gt;&lt;/span&gt; of parent’s class "foo" and NOT overriding. &lt;span style="font-weight:bold;"&gt;Overriding the method would be violating the type check for the Parent class and overloading with the same signature throws an error.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-6812620521497424418?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/6812620521497424418/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=6812620521497424418' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/6812620521497424418'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/6812620521497424418'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2009/04/import-java.html' title='Java Generics: Why I get &quot;name clash&quot; exception when I override methods with different &quot;type&quot; parameter ?'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-5119119890917566196</id><published>2009-04-02T00:19:00.000-07:00</published><updated>2009-08-10T00:28:32.818-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Sql Server'/><category scheme='http://www.blogger.com/atom/ns#' term='Database'/><title type='text'>Remove PK, FK constraint from SQL Server table</title><content type='html'>I'm weak in databases and consult Google every time if I'm new to the concept OR baffled somewhere. Some days back I got simple requirement which is nothing but to drop the PK constraint from a table, Initially I thought it was easy to do but got stuck and finally came up with solution.This is what straight forward thing I did&lt;br /&gt;&lt;pre name="code" class="sql"&gt;&lt;br /&gt;-- Problem: Remove the PK constraint from the table 'test', &lt;br /&gt;-- Solution: &lt;br /&gt;-- 1. Get the table constraint using following query&lt;br /&gt;      SELECT CONSTRAINT_NAME FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS &lt;br /&gt;      WHERE TABLE_NAME = 'test';&lt;br /&gt;-- 2. It returns a column CONSTRAINT_NAME with the list of constraint, like, PK, FK, etc&lt;br /&gt;&lt;br /&gt;--|CONSTRAINT_NAME|&lt;br /&gt;------------------- &lt;br /&gt;--|PK_test        | &lt;br /&gt; &lt;br /&gt;-- 3. The PK constraint name generally starts with "PK_table_name[_xxx]"&lt;br /&gt;-- 4. Remove it using following query &lt;br /&gt;      ALTER TABLE test&lt;br /&gt;      DROP CONSTRAINT PK_test;&lt;br /&gt;-- 5. You just drop the PK constraint from table 'test', hurray !!! :)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Hope this helps someone who is struggling like me :)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-5119119890917566196?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/5119119890917566196/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=5119119890917566196' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/5119119890917566196'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/5119119890917566196'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2009/03/remove-pk-fk-constraint-from-sql-server.html' title='Remove PK, FK constraint from SQL Server table'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-1590800001963053829</id><published>2009-03-16T07:58:00.000-07:00</published><updated>2009-10-14T21:53:43.101-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Hosting'/><category scheme='http://www.blogger.com/atom/ns#' term='Tomcat'/><title type='text'>VirtualHost in Tomcat (Make Tomcat a standalone web server)</title><content type='html'>&lt;span style="font-style: italic;"&gt;Problem:&lt;/span&gt; I want to bind a registered domain name to my web application using Apache Tomcat as a standalone web server(means NO Apache web Server, HTTPD), simple :)&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Environment:&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: left;"&gt;&lt;ul&gt;&lt;li&gt;                                                           Windows Server (64) 2003&lt;/li&gt;&lt;li&gt;                           Apache Tomcat 6.0.18&lt;/li&gt;&lt;li&gt;                           IIS 6&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;br /&gt;Still recently what were we doing to access the web application is,&lt;br /&gt;we are binding domain name "xyz.com" to the IIS which is running on port 80, and then this IIS redirects the page to local instance of tomcat, which is running on port 8080, as http://localhost:8080/WebApp&lt;br /&gt;So when someone hits www.xyz.com the server redirects to the URL as http://xyz.com:8080/WebApp.&lt;br /&gt;Now we need some changes into it&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;1.&lt;/span&gt;Remove port 8080 from URL (pretty easy)&lt;br /&gt;&lt;p style="margin-left: 20px;"&gt;&lt;br /&gt;Open CATLINA_HOME/conf/server.xml and search for number 8080 and replace by 80, save it and you're done. But wait, if you restarted the tomcat, it will throw exception, like ‘JVM_bind: port 80 is already in use’ and this is because of the IIS server running on that default port 80, so stop it...&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;2.&lt;/span&gt;Get the direct access to Tomcat, instead of IIS-Redirecting-Tomcat(Tomcat Virtual Host settings)&lt;br /&gt;&lt;p style="margin-left: 20px;"&gt;&lt;br /&gt;Virtual hosting is easy in a Tomcat, (though many people suggest me, to use Apache web server, HTTPD, which acts like IIS, and then redirect the request to tomcat, which I didn't understand it, yet :)),&lt;br /&gt;We need some edits in following xml&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Caution:&lt;/span&gt; Before modifying this files make sure you had backup this files, so that if anything goes wrong you need not worry about the original files.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;a.&lt;/span&gt; Create a virtual host, which maps xyz.com to the correct application deployed. Note that the &amp;lt;Host&amp;gt element MUST be configured inside &amp;lt;Engine&amp;gt; element, see &lt;a href="http://tomcat.apache.org/tomcat-6.0-doc/virtual-hosting-howto.html"&gt;Tomcat docs&lt;/a&gt; for more details.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;[Caution: Do NOT copy-paste the code as it is, instead edit and write into the file]&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;Host name="www.xyz.com" appbase="Mywebapps" unpackwars="true" &lt;br /&gt;autodeploy="true" xmlvalidation="false" xmlnamespaceaware="false"&gt;&lt;br /&gt;&amp;lt;/Host&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p style="margin-left: 20px;"&gt;&lt;br /&gt;Here, &amp;lt;Host&amp;gt; name is the DNS registered site name “xyz.com” and it will bind all the web application from folder “Mywebapps” to it&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;b.&lt;/span&gt; Create &amp;lt;Alias&amp;gt; element inside the &amp;lt;Host&amp;gt;, which takes the other format of site name and bind to the same virtual host.&lt;br /&gt;&lt;/p&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;Host name="www.xyz.com" appbase="xyzwebapps" unpackwars="true" &lt;br /&gt;autodeploy="true" xmlvalidation="false" xmlnamespaceaware="false"&gt;&lt;br /&gt;      &amp;lt;Alias&gt;xyz.com&amp;lt;/Alias&gt;&lt;br /&gt;&amp;lt;/Host&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;After this just rename your web application's war file as 'ROOT.war', so that's it context path changes from "YOUR_WEB_APP_NAME" to "/" and application can be accessed as 'www.xyz.com', simply.&lt;br /&gt;So finally, this files/directory you got in 'xyzwebapps'&lt;br /&gt;&lt;p&gt;&lt;br /&gt;CATALINA_HOME/xyzwebapps/&lt;br /&gt;./ROOT.war&lt;br /&gt;./ROOT&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;Restart the server, hit http://www.xyz.com and you're good to go :)&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;PS: Here is the beautiful link to implement SSL on Tomcat, you just need a private key from your host provider. Its easy and straightforward.&lt;br /&gt;&lt;a href="http://blog.datajelly.com/company/blog/34-adding-ssl-to-tomcat.html"&gt;http://blog.datajelly.com/company/blog/34-adding-ssl-to-tomcat.html&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-1590800001963053829?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/1590800001963053829/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=1590800001963053829' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/1590800001963053829'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/1590800001963053829'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2009/03/virtualhost-in-tomcat.html' title='VirtualHost in Tomcat (Make Tomcat a standalone web server)'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-435010835112488505</id><published>2009-03-07T07:14:00.000-08:00</published><updated>2009-07-02T21:49:44.007-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Java'/><category scheme='http://www.blogger.com/atom/ns#' term='Java API'/><category scheme='http://www.blogger.com/atom/ns#' term='Quartz'/><title type='text'>Job storage in Quartz using Files,  A FileJobStore Class</title><content type='html'>Quartz supports mainly two types of Job Storage for Scheduler information.&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;    • Memory (non persistent) storage&lt;/span&gt;&lt;br /&gt;&lt;p style="margin-left:20px"&gt;&lt;br /&gt;The memory job storage facility for Quartz is provided by a class called &lt;span style="font-family:Courier;"&gt;org.quartz.simpl.RAMJobStore&lt;/span&gt;, The RAMJobStore is the default, i.e unless you change the configuration, and this is the JobStore that will be used for any Quartz application. Using this JobStore has some advantage&lt;br /&gt;1. Easy to configure, because  already configured by Scheduler as a default&lt;br /&gt;2. It’s fast -  a plain old simple memory access&lt;br /&gt;But, as a computer memory is volatile, when your Quartz application is stopped, it releases the memory back to the operating system. Of course, along with everything else stored in that released memory is the scheduling information.&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;    • Persistent storage&lt;/span&gt;&lt;br /&gt;&lt;p style="margin-left:20px"&gt;&lt;br /&gt;Second is using database for Job storage which implements JobStoreSupport abstract class&lt;br /&gt;Quartz offers two different types of concrete persistent JobStores, each one designed for a specific database environment and configuration:&lt;br /&gt;1. &lt;span style="font-family:Courier;"&gt;org.quartz.impl.jdbcjobstore.JobStoreTX&lt;/span&gt; - Persistent Storage in a Stand-Alone Environment&lt;br /&gt;2. &lt;span style="font-family:Courier;"&gt;org.quartz.impl.jdbcjobstore.JobStoreCMT&lt;/span&gt; - Persistent Storage in an Application Container&lt;br /&gt;(For more information on this two concrete classes see, &lt;a href="http://www.opensymphony.com/quartz/api/"&gt;Quartz Docs&lt;/a&gt;)&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;This storage classes implements the JobStore interface.&lt;br /&gt;&lt;br /&gt;Now to implement the &lt;span style="font-family:Courier;"&gt;FileJobStore&lt;/span&gt; for which saves our jobs in file by using serialization, we need to implement the &lt;span style="font-family:Courier;"&gt;JobStore&lt;/span&gt; interface&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Implementing the JobStore Interface&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;The &lt;span style="font-family:Courier;"&gt;JobStore&lt;/span&gt; interface has 40 methods that must be implemented by any JobStore implementation, including user defined methods. How you implement those methods depends entirely on the type of JobStore that you are building. That doesn't mean that your JobStore will have only 40 methods; this is just the minimum that the interface requires. These 40 methods represent the public contract between a JobStore and the Scheduler.&lt;br /&gt;Let's consider a method,&lt;br /&gt;&lt;span style="font-family:Courier;"&gt;public void schedulerStarted() throws SchedulerException ;&lt;/span&gt;&lt;br /&gt;The Scheduler calls the JobStore's schedulerStarted() method to inform the JobStore that the Scheduler has been started. If you look at the implementation in &lt;span style="font-family:Courier;"&gt;RAMJobStore&lt;/span&gt;, you can see that nothing is done inside this method for this implementation:&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;public void schedulerStarted() throws SchedulerException {&lt;br /&gt; // nothing to do&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The &lt;span style="font-family:Courier;"&gt;org.quartz.spi.JobStore&lt;/span&gt; interface has too many methods to list here, but the API for the JobStore interface can be generalized into the following categories:&lt;br /&gt;&lt;p style="margin-left:20px"&gt;&lt;br /&gt;• Job-related API&lt;br /&gt;• Trigger-related API&lt;br /&gt;• Calendar-related API&lt;br /&gt;• Scheduler-related API&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;Quartz users almost never access or see concrete classes that implement the JobStore interface; they are used internally by the Quartz Scheduler to retrieve job and trigger information during runtime.&lt;br /&gt;Now to implement FileJobStore, there are some important to method to override, eg&lt;br /&gt;&lt;br /&gt;Store job&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;/**&lt;br /&gt;Store the Job&lt;br /&gt;*/&lt;br /&gt;public void storeJob(SchedulingContext ctxt, JobDetail newJob,&lt;br /&gt;           boolean replaceExisting) throws ObjectAlreadyExistsException&lt;br /&gt;   {&lt;br /&gt;         // Here comes some other logic to store various parameters of Job&lt;br /&gt;         jobDetailMap.put(newJob.getName(), newJob);&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre name="code" class="java"&gt;&lt;br /&gt;/**&lt;br /&gt;Called by the QuartzScheduler to inform the JobStore that it should free up all of it's resources because the scheduler is shutting down.&lt;br /&gt;*/&lt;br /&gt;public void shutdown()&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;       log.info("SYSTEM IS SHUTTING DOWN .. SERILAZING THE JOBS ..");&lt;br /&gt;       // A temporary JobDetail object,&lt;br /&gt;       JobDetail jobDetailTemp = null;&lt;br /&gt;       try&lt;br /&gt;       {&lt;br /&gt;           // create the job.txt file to searilaze Jobs&lt;br /&gt;           objOutStream = new ObjectOutputStream(new FileOutputStream("job.txt", false));&lt;br /&gt;          &lt;br /&gt;           // fetch each Job from joDetailMap&lt;br /&gt;           Iterator&amp;lt;Map.Entry&amp;lt;String, JobDetail&amp;gt;&amp;gt; it = jobDetailMap.entrySet().iterator();&lt;br /&gt;           // this list is serilized&lt;br /&gt;           ArrayList&amp;lt;JobDetail&amp;gt; jobDetailList = new ArrayList&amp;lt;JobDetail&amp;gt;();&lt;br /&gt;           while(it.hasNext())&lt;br /&gt;           {&lt;br /&gt;               jobDetailTemp = it.next().getValue();&lt;br /&gt;               // add Jobs to list&lt;br /&gt;               jobDetailList.add(jobDetailTemp);&lt;br /&gt;           }&lt;br /&gt;&lt;br /&gt;           // write to file&lt;br /&gt;           objOutStream.writeObject(jobDetailList);&lt;br /&gt;           objOutStream.flush();&lt;br /&gt;           objOutStream.close();&lt;br /&gt;       } catch (FileNotFoundException fnfex)&lt;br /&gt;       {&lt;br /&gt;           log.error("Problem in reading job file, job.txt; Exception " + fnfex.getMessage());&lt;br /&gt;       } catch (IOException ioex)&lt;br /&gt;       {&lt;br /&gt;           log.error("Problem in output stream; Exception :" + ioex.getMessage());&lt;br /&gt;       }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;You can implement your own method for Job storage or enhance this code; I’m giving the source file of my implementation.&lt;br /&gt;Download: &lt;a href="http://www.4shared.com/file/115674645/a69c7e09/FileJobStore.html" target=_blank&gt;FileJobStore.java&lt;/a&gt;&lt;br /&gt;I know this implementation need some enhancements, as I’m not Java Guru, your comments are welcomed.&lt;br /&gt;Updates: Removed a bug, new revision 1.2 of FileJobStore.java  uploaded !!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-435010835112488505?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/435010835112488505/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=435010835112488505' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/435010835112488505'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/435010835112488505'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2009/03/job-storage-in-quartz-using-files.html' title='Job storage in Quartz using Files,  A FileJobStore Class'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-5668240271824081368</id><published>2009-02-11T22:55:00.000-08:00</published><updated>2009-06-22T23:56:00.798-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='I thought'/><title type='text'>Luck By Chance</title><content type='html'>No, no I’m not here to discuss the latest Farhan Akhtar starred film, &lt;a href="http://en.wikipedia.org/wiki/Luck_by_Chance"&gt;Luck By Chance&lt;/a&gt;.&lt;br /&gt;This actually regarding the Best Java forum on earth, &lt;a href="http://www.javaranch.com"&gt;JavaRanch &lt;/a&gt;where mostly I’m engaged with my post. The forum is very friendly yet professional. Most of the time they have a book promotion, which is usually starts at Monday and ends at Friday, in a same week. This time they gave out the copies of &lt;a href="http://www.coderanch.com/t/429190/IDEs-Version-Control-other-tools/Welcome-Eric-Clayberg-Dan-Rubel"&gt;“Eclipse Plugin”&lt;/a&gt; in 'IDEs, Version Control and other tools' forum section, they draw 4 lucky posters at randomly, and give out book to them, and this time, &lt;a href="http://www.coderanch.com/t/430027/IDEs-Version-Control-other-tools/Winners-Eclipse-Plugins"&gt;I won the book…&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now what is the Luck By chance, because when you post only one answer to this forum and still you won, you need to be lucky and after all it’s my day, isn’t it?&lt;br /&gt;&lt;br /&gt;Many people (Not "really" many , but one) questioned about the correctness of that software, after saw my name who posted only one reply. It’s all your luck and for the matter of fact, I participated in many book promotions earlier, recent one is for &lt;a href="http://www.coderanch.com/t/420508/Struts/Winners-Apache-Struts-Web-Application"&gt;'Apache Struts 2 Web Application Development'&lt;/a&gt; book and I posted nearly 12 to 14 replies, but no luck.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Afterthoughts:&lt;/span&gt; The more I blog, the more you know, I'm full of links!!&lt;br /&gt;Updates: Received book yesterday (22 June 09)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-5668240271824081368?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/5668240271824081368/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=5668240271824081368' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/5668240271824081368'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/5668240271824081368'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2009/02/luck-by-chance.html' title='Luck By Chance'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-1566563359764977308</id><published>2009-01-12T05:04:00.000-08:00</published><updated>2009-03-23T03:55:17.623-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='C'/><category scheme='http://www.blogger.com/atom/ns#' term='ODBC'/><title type='text'>How to fetch NULL data into C-ODBC program?</title><content type='html'>From last two months I’m working on C-ODBC project, despite my expertise in Java. This was I encountered while development.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Problem&lt;/span&gt;: C-ODBC API does not provide any function which fetch NULL data without throwing a runtime error.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Solution&lt;/span&gt;: Need to provide an &lt;span style="font-style:italic;"&gt;indicator&lt;/span&gt;, which get set when row data contained NULL for that specific column.&lt;br /&gt;&lt;br /&gt;1. Define the long typed variable for holding indication about NULL data:  &lt;br /&gt;&lt;pre name="code" class="c"&gt;&lt;br /&gt;SQLINTEGER i_first_name, i_last_name, i_age; // i for indicator&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;2. Passed this indicator variable to SQLBindCol function:&lt;br /&gt;&lt;pre name="code" class="c"&gt;  &lt;br /&gt;  SQLBindCol(hstmt, 1, SQL_C_CHAR, first_name, 100, &amp;i_first_name);&lt;br /&gt;  SQLBindCol(hstmt, 2, SQL_C_CHAR, last_name, 100, &amp;i_larst_name);&lt;br /&gt;  SQLBindCol(hstmt, 3, SQL_C_CHAR, age, 100, &amp;i_age);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;  More Information: &lt;a href="http://msdn.microsoft.com/en-us/library/ms711010.aspx"&gt;http://msdn.microsoft.com/en-us/library/ms711010.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;3.   Check whether we fetched any NULL data into a column by checking,&lt;br /&gt;&lt;pre name="code" class="c"&gt;&lt;br /&gt;  if(i_first_name == SQL_NULL_DATA)&lt;br /&gt;  {&lt;br /&gt;       // I put a “null” string into fist_name variable.&lt;br /&gt;       strcpy(fist_name, “null”);&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;  This code copies “null” string into that first name column, else put the value you  just fetched.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I Searched/Googled this problem, but nothing found specifically discussing this issue, that’s why I wrote one, If you come across more detailed article regarding this, then please let me know..&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-1566563359764977308?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/1566563359764977308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=1566563359764977308' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/1566563359764977308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/1566563359764977308'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2009/01/how-to-fetch-null-data-into-c-odbc.html' title='How to fetch NULL data into C-ODBC program?'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-8127181003926226341</id><published>2008-11-16T22:38:00.000-08:00</published><updated>2009-09-10T03:48:42.914-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='I thought'/><title type='text'>A CAT crossed my (Life's ??) path !!</title><content type='html'>Yesterdays, a thousands of young grads appeared for CAT, the MBA entrance for top biz school in India and considered as one of the toughest exam in world!&lt;br /&gt;&lt;br /&gt;I'm not business or management guy, nor I'm gonna explain u the structure or importance of CAT, either.. While many of my good friends preparing for it from last 2 years, some just waked up with Saturday night hangover and went for the exam. They realized me (or I'm pretend to be realized) the importance of CAT, the MBA n some same stuff for good life. But neither I'm gonna do that for next 5-6 years nor I got that much money...&lt;br /&gt;&lt;br /&gt;So my technical is good for me... Let’s see what life brings to me (w/o MBA)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-8127181003926226341?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/8127181003926226341/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=8127181003926226341' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/8127181003926226341'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/8127181003926226341'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2008/11/cat-crossed-my-lifes-path.html' title='A CAT crossed my (Life&apos;s ??) path !!'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-1657259688390166361</id><published>2008-10-08T05:35:00.000-07:00</published><updated>2009-08-10T00:04:33.533-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='MySQL'/><category scheme='http://www.blogger.com/atom/ns#' term='Tomcat'/><title type='text'>com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception</title><content type='html'>&lt;span style="font-weight: bold;"&gt;com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception:&lt;br /&gt;** BEGIN NESTED EXCEPTION **&lt;br /&gt;java.net.SocketException&lt;br /&gt;MESSAGE: Software caused connection abort: recv failed&lt;br /&gt;STACKTRACE:&lt;br /&gt;java.net.SocketException: Software caused connection abort: recv failed&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style: italic;"&gt;Environment: &lt;/span&gt;Apache Tomcat 6.0.14 with MySQL 5.2&lt;br /&gt;&lt;br /&gt;This is the exception which was the night mare for many developers who used MySQL with Java Web application in Tomcat server. Before explaining the cause let me told you that, the exception has responsible for pulling my hair for almost 2 weeks, with little use of Googling and MySQL Forum!&lt;br /&gt;&lt;br /&gt;Particularly, the problem was, I lost my connection object when server is idle for 24 to 34 hours, so any request comes after this time interval results in above exception.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-style:italic;"&gt;Disclaimer:&lt;/span&gt; The below explanation is as per my understanding and as I’m not an architecture of MySQL JConnector nor Apache DBCP API, Comments &amp;amp; Suggestions are welcomed, &lt;a href="http://forums.mysql.com/read.php?39,16257,16257#msg-16257"&gt;See this link&lt;/a&gt; from where I derived my explanation&lt;br /&gt;&lt;br /&gt;This exception, in my case, comes when a connection has opened by MySQL on the request of Apache DBCP, but which is no more (valid) connected to actual Data Source!! So that when we close the connection by&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;connection.close();&lt;/span&gt;&lt;br /&gt;its actually closes the resource opened with Apache DBCP source , but not with MySQL instanced connection , so that connection from MySQL to DBCP source remained in memory for the time_out period(If this time elapsed the connection get automatically closed by MySQL, its an environment variable).&lt;br /&gt;So there is two connection opened, one from application to DBCP and another from DBCP to MySQL (TCP/IP link). See for diagram&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_2It7r8gkYdE/SXQ_4qcW7kI/AAAAAAAAACA/xUjiYg-SNWc/s1600-h/clip_image002.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 224px;" src="http://3.bp.blogspot.com/_2It7r8gkYdE/SXQ_4qcW7kI/AAAAAAAAACA/xUjiYg-SNWc/s320/clip_image002.jpg" alt="" id="BLOGGER_PHOTO_ID_5292925704765632066" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now, the solution part,&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The problem is underlying structure of Apache DBCP code, which actually opens the connection with MySQL, but we can’t forced or tell the DBCP to close the connection, but we can take an working, valid connection from server, by telling them to validate it before returning new connection from Data Source !&lt;br /&gt;&lt;br /&gt;For that, we have to pass some attribute to server!&lt;br /&gt;&lt;br /&gt;So your context.xml looks like,&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;context&amp;gt;&lt;br /&gt;&amp;lt;Resource auth="Container"&lt;br /&gt;driverClassName="com.mysql.jdbc.Driver"&lt;br /&gt;maxActive="5"&lt;br /&gt;maxIdle="1"&lt;br /&gt;maxWait="10000"&lt;br /&gt;name="jdbc/TestDS"&lt;br /&gt;username="root"&lt;br /&gt;password="password"&lt;br /&gt;type="javax.sql.DataSource"&lt;br /&gt;url="jdbc:mysql://127.0.0.1:3306/TestDS?jdbcCompliantTruncation=false&amp;amp;elideSetAutoCommits=true&amp;amp;useLocalSessionState=true&amp;amp;maintainTimeStats=false""&lt;br /&gt;removeAbandoned="true"&lt;br /&gt;logAbandoned="true"&lt;br /&gt;removeAbandonedTimeout="3600"&lt;br /&gt;validationQuery="SELECT 1"&lt;br /&gt;testOnBorrow="true"&lt;br /&gt;testOnReturn="false"&lt;br /&gt;testWhileIdle="true"&lt;br /&gt;timeBetweenEvictionRunsMillis="1000"&lt;br /&gt;minEvictableIdleTimeMillis="60000"&lt;br /&gt;poolPreparedStatements="true"&lt;br /&gt;maxOpenPreparedStatements="10"/&amp;gt;&lt;br /&gt;&amp;lt;/context&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The explanation of above attribute can be viewed here:&lt;br /&gt;&lt;a href="http://commons.apache.org/dbcp/configuration.html"&gt;http://commons.apache.org/dbcp/configuration.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;This will solve the above exception !!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-1657259688390166361?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/1657259688390166361/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=1657259688390166361' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/1657259688390166361'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/1657259688390166361'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2008/10/commysqljdbccommunicationsexception.html' title='com.mysql.jdbc.CommunicationsException: Communications link failure due to underlying exception'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_2It7r8gkYdE/SXQ_4qcW7kI/AAAAAAAAACA/xUjiYg-SNWc/s72-c/clip_image002.jpg' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8181692097334192490.post-6034061736376598905</id><published>2008-10-01T22:00:00.000-07:00</published><updated>2011-04-08T08:25:57.146-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='I thought'/><title type='text'>Hello , Mike Testing..</title><content type='html'>This is my first (or last, the way blogger stacked them) blog and I`m pretty excited . In this coming years you can expect my thoughts on various technical and non technical issues.&lt;br /&gt;&lt;br /&gt;I`m not kinda writer person, So your comment are always welcome,&lt;br /&gt;&lt;br /&gt;So , Take my thoughts ..&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8181692097334192490-6034061736376598905?l=techmythoughts.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://techmythoughts.blogspot.com/feeds/6034061736376598905/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=8181692097334192490&amp;postID=6034061736376598905' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/6034061736376598905'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8181692097334192490/posts/default/6034061736376598905'/><link rel='alternate' type='text/html' href='http://techmythoughts.blogspot.com/2008/10/hello-mike-testing.html' title='Hello , Mike Testing..'/><author><name>Sagar Rohankar</name><uri>https://profiles.google.com/112351867415775761750</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh4.googleusercontent.com/-Bikt-JNR8qU/AAAAAAAAAAI/AAAAAAAAAts/Pl4q6FX-oY0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry></feed>
