Monday, 28 September 2015

Simple steps to convert DOC to PDF

To convert DOC to PDF, we try to find the apps/online though this functionality is there in Microsoft word only :)

Basic thing is to find Create PDF/XPS Document option from menu.

To get this option there are multiple ways, one of them is

1) Open the Word doc.
2) Go to File menu >> Save and Send >> File Types >> Create PDF/XPS Document >> Create PDF/XPS
3) Click on it and save the PDF file with name as you need.
And we are done.

Please find below image for reference.


Wednesday, 23 September 2015

Oracle Jobs

Creating a oracle to job :

BEGIN

DBMS_SCHEDULER.create_job (    job_name        => 'Test_create_job',    

job_type        => 'PLSQL_BLOCK',    

job_action      => 'BEGIN DBMS_STATS.gather_schema_stats(''SCOTT''); END;',-- job action will be procedure which you want to invoke    

start_date      => SYSTIMESTAMP,    

repeat_interval => 'freq=hourly; byminute=0',    

end_date        => NULL,    

enabled         => TRUE,    

comments        => 'Job defined entirely by the CREATE JOB procedure.');

END;

Note : There are many other values for repeat_interval

Stop the Job:

BEGIN

DBMS_SCHEDULER.stop_job (job_name => 'Test_create_job');

END;

Drop the job :

BEGIN  

DBMS_SCHEDULER.drop_job (job_name => 'Test_create_job');

END;

Enable job:

BEGIN

DBMS_SCHEDULER.enable (name => 'Test_create_job');

END;

Disable he job:

BEGIN

DBMS_SCHEDULER.disable (name => 'Test_create_job');

END;

Update any job attribute :
BEGIN
DBMS_SCHEDULER.set_attribute (
    name      => 'Test_create_job',
    attribute => 'repeat_interval',
    value     => 'freq=hourly; byminute=30');
END;

You can check details of the job using follwoing query :

SELECT OWNER, JOB_NAME, JOB_CREATOR, START_DATE, NEXT_RUN_DATE, ENABLED, STATE,REPEAT_INTERVAL FROM dba_scheduler_jobs ds;

Tuesday, 22 September 2015

Custom Logging Appender for log4j version 2 based xml

Requirement :
To have our custom appender where we can play with the log files(names, size etc) which we want to create.

Solution :
Create our own appender and use it to get log files.

Used Tech :
1) log4j-api-2.2.jar
2) log4j-core-2.2.jar

Path where to put XML:
Xml under "WEB-INF\classes\" folder of  custom war.

Log4j XML file:
Please find the path for "log4j2.xml"
https://drive.google.com/open?id=0BwyaWKtCo9z7NUJwbEVaY3pIRjg

Custom Plugin(Java File) created: "LogCustomRollingFileAppender.java"
Java file which is customized version of our plugin. 
https://drive.google.com/open?id=0BwyaWKtCo9z7aEpXSExGZ29TMFU

Wednesday, 5 August 2015

To open the port 3306 or other

Tried to open port 3306 using following steps:

i. Open Control Panel from the Start menu.
ii. Select Windows Firewall.
iii. Select Advanced settings in the left column of the Windows Firewall window.
iv. Select Inbound Rules in the left column of the Windows Firewall with Advanced Security window.
v. Select New Rule in the right column.
vi. Select Port in the New Inbound Rule Wizard and 

     then click Next.
vii.Select which protocol this rule will apply to (TCP or UDP), 

      select Specific local ports, 
      type a port number (80), 
      port numbers (80,81), 
      or a range of port numbers (5000-5010) and 
      then click Next.
viii.Select Allow the connection and 

      then click Next.
ix. Select when this rule applies (check all of them for the port to always stay open) and        then click Next.
x. Give this rule a name and 

      then click Finish to add the new rule.

Thursday, 2 July 2015

JDBCUtility : Find the generic methods to interact with DB

JDBC Utility :

Utility in java to interact with DB, So find some generic functions and use them directly like.
1) getting connecion
2) getIntValue
3) runQuery
4) runIsertStatement
5) runBatchIsertStatement
6) prepareInsertStatement
7) executeProcedure
and many more...

Pelase find the code attached below.
https://drive.google.com/open?id=0BwyaWKtCo9z7SW5LNDZvQi1Gcm9pMzFrSGFWVlpiRXdRdTdr

Sunday, 28 June 2015

Loading property file in java

Loading property file in java code.

Loading property file can be used for following purposes :
i) If you want to configure a value which need to be accessed by your code, then its easy to define in property file and easily configurable.
ii) log4j.property file is also required to pick sometimes if you need sepearate logging mechanism.

Following is the general code to pick property file :

package com.test.timer.utils;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;


public class PropertyUtils {
//protected static final Logger LOGGER   = LogFactory.getLogger(PropertyUtils.class);
private static Properties prop = null;

public static void init(){

//LOGGER.info("PropertyUtils.init called");
InputStream timerPropertiesIS = null;
try {
timerPropertiesIS = new FileInputStream(TimeEJBConstants.PROPERTIES_FILE_NAME);

} catch (FileNotFoundException e) {
//LOGGER.info("FileNotFoundException",e);
}

// props for logger
prop = new Properties();
try {
prop.load(timerPropertiesIS);
//LOGGER.info("Property file "+TimeEJBConstants.PROPERTIES_FILE_NAME+" loaded ");
} catch (IOException e) {
//LOGGER.info("FileNotFoundException",e);
}finally{
try {
timerPropertiesIS.close();
} catch (IOException e) {
//LOGGER.info("IOException",e);
}
}

}

public static String getProperty(String propName) {
return prop.getProperty(propName);
}

public static void init(Properties prop2) {
prop = prop2;

}

}

//Here,
TimeEJBConstants.PROPERTIES_FILE_NAME is name of property file present in domain path
like below :
public static final String PROPERTIES_FILE_NAME ="./CustomerTimer.properties";


Now, wherever you want to use the property file just call init() method 
PropertyUtils.init();
and use the variable defined in file as follows:
Integer.valueOf( PropertyUtils.getProperty(TimeEJBConstants.PRIORITY_Q_ONDEMAND));
for varaible :
public static final String PRIORITY_Q_ONDEMAND ="priority_On_Demand";


where varaible defined in CustomerTimer.properties is like
priority_On_Demand= 8

Saturday, 20 June 2015

Technical Interview Questions

A Short and concise document for technical interview questions comprises of different subjects. Surely help you in your way :)

https://drive.google.com/open?id=0BwyaWKtCo9z7UjQyS3VIc25xNGM&authuser=0

More coming up soon...

Sunday, 24 August 2014

Knowledge Transfer


1) Who hosted the Game which was initially called as British Empire Games 2014 and who is going to host in 2018?
Ans :
    2014     
    Glasgow    
Scotland
2018
Australia

2) Story of Girlfriend and Boyfriend:
Boyfriend had collected many gold coins. He did not want anybody to know about him. One day his girlfriend asked, “How many gold coins do we have?”  After pausing a moment, he replied,” Well! If I divide the coins into two unequal numbers, then 48 times the difference between the two numbers equals the difference between the square of the these numbers.” Girlfriend looked puzzled. Can you help her by finding out how many gold coins boyfriend has?
Ans :48
Exp :Two unequal numbers : x and y
48(x-y)=x^2 – y^2
ð                      x+y=48

3) 3, 6, 18, 90, 63o,?
Ans :6930
Exp : 3, 3*2=6, 6*3=18, 18*5=90, 90*7=630, 630*11=6930
  
4) Introducing a boy, a girl said, "He is the son of the daughter of the father of my uncle." How is the boy related to the girl?
Ans : Brother/ Cousin Brother

The father of the boy's uncle the grandfather of the boy and daughter of the grandfather sister of father.

5) If 15th August, 2008 is Friday then what day will fall on 15th August, 2018?
Ans :Wednesday

6)Name any three countries which share the same date of independence as India (excluding India, holiday name might be different for them).
Ans :
August 15
1971
Independence from the United Kingdom in 1971
August 15
1960
Independence from France in 1960.
August 15
1947
Independence from the United Kingdom on 15 August 1947.
August 15
1945
Independence from Japan was declared on March 1, 1919. Holiday is celebrated on August 15, anniversary of independent Korean governments creation on August 15, 1948

Liechtenstein

August 15

7) The owner of a jewellery shop hired 3 watchmen to guard his diamonds, but a thief still got in and stole some diamonds. On the way out, the thief met each watchman, one at a time. To each he gave ½ of the diamonds he had then, and 2 more besides. He escaped with one diamond. How many did he steel originally.
Ans :36
Exp :No. of diamonds before he gave some diamonds to the third watchman = x-(x/2+2)=1
ð              X-4/2=1  àx=6
Hence he had 6 diamonds before he gave 5 to the third watchman.
Similarly, x-4/2=6  à x=16 (number of diamonds before giving to second watchman)
And also x-4/2=16 à x=36
Therefore, thief stole 36 diamonds

8) 480, 240, 720, 180, 900, 150, ?
Ans :1050
Exp: 480, 480/2=240, 240*3=720, 720/4=180, 180*5=900, 900/6=150, 150*7=1050

9) Deepak said to Nitin, "That boy playing with the football is the younger of the two brothers of the daughter of my father's wife." How is the boy playing football related to Deepak?
Ans : Brother
Father's wife mother. Hence, the daughter of the mother means sister and sister's younger brother means brother. Therefore, the boy is the brother of Deepak.

10)What is the angle between the minute hand and the hour hand when the time is 03:40 hours?
Ans: 130
The total angle made by the minute hand during an hour is 360o. If it takes 360o for an hour, it will take 40/60*360= 240o. The angle between the hour hand the minute hand will therefore, be somewhere between 240 - 90 = 150o, as the hour hand is between 3 and 4.
The angle made by the hour hand when it moves from say 3 to 4 will be 30
o. That is the hour hand makes 30o during the course of an hour.
The hour hand will therefore, move 40/60*30
= 20o.
Therefore, the net angle between the hour hand and the minute hand will be 150 - 20 = 130
o. 

Tuesday, 8 July 2014

How to deploy a Eclipse Java Web Dynamic Project on TomCat


  1. Setup Apache Tomcat on your Sys.
    • Usually all you have to do is download the current version, unzip it, and start it by running apache-tomcat-folder\bin\startup.bat. (You can also donwload an installer and set it up as windows service. Check this link for more details).
    • Make sure you test it before continuing (open its address on a browser, something like http://yourinstaceaddress.com:8080/).
  2. Export your web application .war file
    • In Eclipse, right click on a Web project and select Export. Then select WAR file in the Export window and then select Next. Choose the project, the .war file name and folder to export. More detailed explanation can be found here and here (with pictures).
  3. Deploy the .war file to your Tomcat Server
    • The, by far, simplest way to do this is to place your .war (say myapp.war) file in your apache-tomcat-folder\webapps\ folder.
  4. Test your web app

Saturday, 21 June 2014

Install Decompiler in Eclipse Helios

Simple steps need to follow to install Decompiler,makes your life easy :

Steps:
1)  Open Eclipse IDE of Helios.
2) Click Help->Install New software.
3) Paste URL(http://feeling.sourceforge.net/update) and give name you want like Decompiler.
4) Select the Eclipse Class Decompiler.
5) Click on Next and accept agreements.
6) Install it, some ok and next.
7) Restart Eclipse and check now.

You will have decompiler installed, njy :)