Posts

Spring Auto-Wiring Beans with @Autowired annotation

In Spring, you can use @Autowired annotation to auto wire bean on the setter method, constructor or a field. There are two ways to can achieve it : 1.Using <context:annotation-config />     Just Add Spring context and <context:annotation-config /> in bean configuration file <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"     xmlns:tx="http://www.springframework.org/schema/tx"     xmlns:context="http://www.springframework.org/schema/context"     xsi:schemaLocation="http://www.springframework.org/schema/beans     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd     http://www.springframework.org/schema/aop     http://www.springframework.org/schema/aop/spring-aop.xsd     http://www.springframework.org/sche...

Error:No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional one here

To solve this problem. You have to do two things: 1. mark the DAO as transactional or function which is doing database call like:   @Transactional    public class EmployeeDaoImpl  extends DaoImpl implements EmployeeDao{  ///// }            OR @Transactional     public long addEmployee(Employee employee) {         System.out.println("Employee:"+employee );         long id = employeeDao.addEmployee(employee);         System.out.println("Id1: " );         return id;     } 2. Enable the annotation driven transcation management in applicationContext.xml (where your beans are defined): <beans xmlns="http://www.springframework.org/schema/beans"     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="ht...

Keyboard Shortcuts That Work in All Web Browsers

Tabs Ctrl+1-8 – Switch to the specified tab, counting from the left. Ctrl+9 – Switch to the last tab. Ctrl+Tab – Switch to the next tab – in other words, the tab on the right. ( Ctrl+Page Up also works, but not in Internet Explorer.) Ctrl+Shift+Tab – Switch to the previous tab – in other words, the tab on the left. ( Ctrl+Page Down also works, but not in Internet Explorer.) Ctrl+W , Ctrl+F4 – Close the current tab. Ctrl+Shift+T – Reopen the last closed tab. Ctrl+T – Open a new tab. Ctrl+N – Open a new browser window. Alt+F4 – Close the current window. (Works in all applications.) Mouse Actions for Tabs Middle Click a Tab – Close the tab. Ctrl+Left Click, Middle Click – Open a link in a background tab. Shift+Left Click – Open a link in a new browser window. Ctrl+Shift+Left Click – Open a link in a foreground tab. Navigation Alt+Left Arrow, Backspace – Back. Alt+Right Arrow, Shift+Backspace – Forward. F5 – Reload. Ctrl+F5 – Reload and...

Use mySQl setup from your virtual machine

Image
Have you ever faced a situation where you want to use your MYSQl from your virtual machine. i,e your MYSQL set up is on the windows and your linux is on VM player and you want to use it rather than installing it again on linux box. If yes, Then here is the solution. My System configuration where I have tested. OS : Windows 7 MYSQL: version 5.5 on windows RHEL 5 on VM player Step: 1 . Open MYSQL workbench 5 2.  Open your MYSQL from server Administrator. 3.  Goto Security -> Users and Privileges 4.  Replace 'localhost' with '%' in limited connectivity to host matching box. And you are done here..:) All credit goes to my Manager..Thanx a lot..:)

List all xml files from the JAR.

Do you want to know which all files are in the jar without extracting it.? This is a small tutorial where I am listing all the xml files. import java.io.IOException; import java.util.ArrayList; import java.util.Enumeration; import java.util.List; import java.util.jar.JarEntry; import java.util.jar.JarFile; /**  * List the name of all xml which is in given jars  *  * @author abdul  */ public class ListXmlFiles {     /* Stores the xml file name*/     List<String> list = new ArrayList<String>();     public List<String> getList() {         return list;     }     /**      * @param args      * @throws IOException      */     public static void main(String[] args) throws IOException {         ListXmlFiles xmlFiles = new ListXmlFiles();  ...

Windows Command Prompt Tricks You Probably Don’t Know

1. Send a Command’s Output to the Clipboard Note: This will work for any command. Without doing copy and paste the output, We can send the output directly to the clipboard. ipconfig | clip 2. Open Command Prompt From a Folder Do you want to open the command promp within a folder from explorer ? All you have to do is hold shift while right  clicking on a folder and the option will appear in the context menu. 3. Command History We can view our past command  i,e using doskey command. doskey /history 4. Drag and Drop Files to Change the Current Path Another neat trick if you are not a fan of opening a command prompt from the context menu is the ability to drag and drop folders onto the prompt and have it automatically enter the path of the folder. 5. Run Multiple Commands In One Go Want to run multiple command at once?  You can do this by linking them with double ampersands. ipconfig && netstat

How to read properties file using ANT

Suppose You have to access some properties (from a file), which are already defined in my build file. To be able to access the properties We can use the build attribute of the property task.  build.properties #Release information #Thu Oct 14 16:25:12 CEST 2004 build.number=115 release.version=0.4 release.name=framework   Ant Example Target <target name="read.properties"> <!-- Read the properties from the release of the framework --> <property file="build.properties" prefix="build"/> <echo message="${build.build.number}"/> <echo message="${build.release.version}"/> <echo message="${build.release.name}"/> </target>    Output Buildfile: C:\build.xml read.properties: [echo] 115 [echo] 0.4 [echo] framework BUILD SUCCESSFUL Total time: 3 seconds