Wednesday, July 12, 2017

Get connection pool usage in WebSphere

./wsadmin.sh -f test.jy -lang jython -port 8879 >> log.txt

Contents of test.jy will be

objectName=AdminControl.queryNames("*:type=DataSource,*")
templateArray=objectName.split('\n')
for object in templateArray: print AdminControl.invoke(object,'showPoolContents')

Now log.txt will contain the connection pool information for all the datasources.

This may be very useful when you want to know the connection pool usage of datasources.

 Usually , you will have security enabled  in your environment. In those cases, give the username and password fields as below.

 ./wsadmin.sh -f test.jy -lang jython -port 8879 -username admin -password password >> log.txt

 Otherwise  , you may keep checking the log.txt to see for any prompts . If there is any prompt for certificate acceptance or username, password.
Then you give the values accordingly on the prompt and connection pool datasource log will be generated after that.

Wednesday, March 1, 2017

Fixing indentation errors in python

Check for indentation error in python
python -m tabnanny yourfile.py
 
Then if you are using PyCharm as text editor then 
go to Code , reformat code 


There will be similar options in other text editors as well

Wednesday, February 15, 2017

Get rid of windows user getting locked everytime

If  you have recently changed your password and your user id is getting locked on a windows system in a LAN network.
 Then, this can be due to your connection  to a network share.
 The connection is using the old password from cache and  locking your ID  everytime .

Procedure to fix is as below :

type "net use" in command prompt
This will display all your connected sessions to network share

Now, Disconnect the network drive
Once again , type "net use" in command prompt .

Now type "klist purge" in command prompt.
This will remove the Kerberos authentication ticket from the machine . This was the one which was locking you everytime.

Thats it.

Thursday, February 2, 2017

Learning Java

Static methods in java belong to the class (not an instance of it). They use no instance variables and will usually take input from the parameters, perform actions on it, then return some result. 

Instances methods are associated with objects and, as the name implies, can use instance variables.


My Observation:
 If you try to invoke a static method using an instance object, you only get a warning that static method must be accessed in  a static way . Code will still run.  


An abstract class can have method implementations.
 

An abstract method does not have any implementation.
Serialization will convert the object into byte array and that can be saved  on disk which can be deserialized later . 

EJB is a part of JAVA EE or J2EE (Enterprise edition) .
J2SE is the standard edition of JAVA.
Hibernate is the open source api developed in Java only .
Basically in EJB , you have a remote interface ( to call the EJB remotely ) ,
a local interface or Home interface  ( to call the EJB locally ) and an implementation class.

A message driven bean only has an implementation class.

All the three Enterprise Java Bean's namely session bean, entity bean and message driven beans are collectively called as Enterprise beans as well .

sql commands

Find version of Oracle database instance 
 
SELECT * FROM V$VERSION
or
SELECT version FROM V$INSTANCE
 
 
Find the current ORACLE_SID you are logged in 
 
sqlplus sys as sysdba;

select name from v$database;
select instance from v$thread;
select ora_database_name from dual;
 
Find the current schema name you are logged in 

select sys_context('userenv','instance_name') from dual; 
select user from dual; 
select * from global_name; 
 
 
Find location of alert logs, alert log file name will be alert_ORACLE_SID.log
 
show parameter background;  
 
 
To find out the location of diagnostic info like trace , logs etc. 
select * from v$diag_info; 

Wednesday, February 1, 2017

MicroSoft Office Tips and Tricks

In Word 2013 and Word 2010 you can go to specific page in the Word document using the Find and Replace dialog.
To display the Find and Replace dialog, Navigate to Home menu and click on the drop down arrow under Find menu at the right corner


Microsoft excel go to next line in cell
  1. Double-click the cell in which you want to insert a line break.
  2. Click the location where you want to break the line.
  3. Press Alt+Enter to insert the line break.



Tuesday, January 31, 2017

Create first hibernate project

Create a Java Project



Click Next and Finish


Right Click the project and create new folder lib


Download hibernate with all dependencies  from the below link



And copy paste to the lib folder


Create a new Java Package


Create a new Class


We have a table login with two columns

Accordingly that
We write the following code in aHibClass.java
package aHibPackage;

public class aHibClass {

   private String UserId;
   private String Password;
   
   public String getUserId()
   {
   return UserId;
   }
   public void setUserId(String UserId)
   {
   this.UserId=UserId;
   }
   public String getPassword()
   {
   return Password;
   }
   public void setPassword(String Password)
   {
   this.Password=Password;
   }

The file aHibClass.class is also referred to as persistence class file .
   
Right Click the package , create a new file login.hbm.xml and click finish




The file login.hbm.xml is also referred to as mapping file .
In the mapping file , we have mentioned about the table and its columns . The id tag is used for the column which is the primary key and rest of the columns are referred as property.

Now , we will create the configuration file .

Right click the src under the project and create a new file hibernate.cfg.xml  with the contents as below
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
oracle.jdbc.driver.OracleDriver
jdbc:oracle:thin:@localhost:1521:bph
ashish
password
org.hibernate.dialect.Oracle10gDialect
false
false
update




create .If we are assigning this value as create,it will create table in database automatically when we run the application.

Download the Oracle  JDBC driver jar file and add it to the build path of the project for the driver class file.


Now , we create the test class that inserts the record
HibTest with the main method

package aHibPackage;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class HibTest {
public static void main(String[] args) {
       Configuration cfg = new Configuration();
         cfg.configure("hibernate.cfg.xml");
         SessionFactory factory = cfg.buildSessionFactory();
        Session session = factory.openSession();
        aHibClass login = new aHibClass();
        login.setUserId("Ashish1");
        login.setPassword("Password2");
         Transaction tx = session.beginTransaction();
           session.save(login);
            tx.commit();
           session.close();
           factory.close();
           System.out.println("Objectis  saved successfully");
   }

}

Right click the project and make sure all the jars added earlier into lib folder are present in the build path of the project. If not , add them manually.


Getting the error
The type java.lang.AutoCloseable cannot be resolved. It is indirectly referenced from required .class files   .



Added an alternate JRE System Library (JDK 1.7.0_80) as my default JRE System library seemed to be out of date







Getting the error

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/hibernate/cfg/Configuration : Unsupported major.minor version 52.0
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
   at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
   at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
   at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
   at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
   at java.security.AccessController.doPrivileged(Native Method)
   at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
   at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
   at java.lang.ClassLoader.loadClass(ClassLoader.java:358)



Downloaded the jdk 1.8 version and added it to the project build path .

Final build path looks as below
Earlier , I have removed the JBoss related jars but I have to add them later as I was getting few Class Not Found exceptions .


Now , we can run HibTest.java as a Java application and test the Sample Hibernate Java code.

This code is simpler in a way than EJB as in EJB , we have to define objects mapped to database also in a java class file whereas here we have the mapping in a xml file .


Hibernate is perfectly suited for creating mapping files . Later , we can use either Hibernate or J2EE ( EJB session beans ) to include logic and DML statements.









Wednesday, January 25, 2017

Income TAX Faq

Who can claim an HRA exemption

1) Living in rented house and paying rent for the same.
2) You can not pay rent to yourself in case you are owner or co-owner of house.
3) If you are staying with parents , its perfectly legal to pay rent to your parents.
4) But at the same time , you cannot pay rent to your spouse if she is the owner of house.
5) A Self employed / Businessman / Salaried without HRA Component can also claim HRA exemption if he is living in rented house.

For more details , you can further search in google .
Below is one of the links with more details
http://www.nitinbhatia.in/personal-finance/hra-house-rent-allowance/


Tax deduction on principal payment and interest payment
When you are owner or co-owner of the house , you can claim tax deduction on principal payment and interest payment .
At the same time , if you are not living in the house and renting out the property , you have to show your rental income irrespective of who is receiving the rent .Being a co-owner does not mean that you can avail the tax deduction on principal payment and interest payment and
later on show the rental income as your spouse income or parents income .

The amount paid as Repayment of Principal Amount of Home Loan by an Individual/HUF is allowed as tax deduction under Section 80C of the Income Tax Act. The maximum tax deduction allowed under Section 80C is Rs. 1,50,000. (Increased from 1 Lakh to Rs. 1.5 Lakh in Budget 2014)

The maximum tax deduction allowed under Section 24 of a self-occupied property is subject to a maximum limit of Rs. 2 Lakhs (increased in Budget 2014 from 1.5 Lakhs to Rs. 2 Lakhs).

For more details , you can further search in google .
Below is one of the links with more details
http://www.charteredclub.com/tax-benefit-on-home-loan/

Professional Tax

Professional tax is imposed by state governments of India .I saw this in my payslip when I moved to Karnataka from Uttar Pradesh.


What is the due date for filing return? 
The due date for filing return is 31st July of assessment year .
Assessment Year comes after the financial year . So if the financial year is 2015-16 , the assessment year is 2016-17 . And the due date for filing return of financial year 2015-16 will be 31st July 2016 . Sometimes it is extended to 31st August .

What kind of forms are used for salaried persons ?
Usually , ITR1 is used by employees having salaries less than 50 Lacs.
Make sure to check carefully which form has to be used before applying for return.


What is 112A and 115AD ?
Both are  in reference to the long term capital gain .

What is 111A?
111A is in reference to the short term capital gain .

Please note that above stated rules can become outdated with time . Make sure to check the latest developments on Govt. Sites.

Calling an EJB from SCA module

Create an import EJBPrint with same interface as EJB remote interface .
You should have added the EJB client jar to J2EE module dependencies of SCA module.




Now drag and drop a Java Component Component1 on the Assembly diagram .


Create an new interface . Create a new reference to the above created import EJBPrint .
Right Click the component and generate implementation.This will generate a class file (java source code)
Add code in your generated java file under the to be implemented block. The to be implemented method name will be same as
the operation name in the interface of Component1.
Following is an example code

        System.out.println("Calling EJB");
        ServiceManager manager = new ServiceManager();
        AEJBClassRemote RemoteEJBObject=(AEJBClassRemote)manager.locateService("AEJBClassRemotePartner");
        RemoteEJBObject.print();
        System.out.println("called imported EJB");
       
where
AEJBClassRemote is the remote interface of EJB and RemoteEJBObject.print() is the method invocation on object .
ServiceManager manager = new ServiceManager(); , manager.locateService("AEJBClassRemotePartner"); is the standard step to locate
the import component and AEJBClassRemotePartner is the reference to import EJBPrint from the Java Component Component1.








Now , go to SCA module , dependencies and include EJB client jar to be deployed with module .






Monday, January 23, 2017

Create a simple SCA module

Go to File , New , Module in the Business Integration Perspective
Give the module name as aSCAModule



















Right Click Integration Logic and create new Business Process



 

Select MicroFlow





Put a snippet in between Receive and Reply 












Go to snippet , properties
Drag and Drop  expression on the visual palette , write a string inside the expression box and
print to log using the drag and drop standard visual snippet


















Go to aSCAModule, Assembly diagram  and drag ,drop the aBusinessProcess just created 


Save the changes , Do a clean and build and publish changes to the server .

Your first SCA module is ready


You can right click the module and test the module .
You will see that the string message is printed in the server log .