Posts

Showing posts from 2015

Spring MVC with Sqlite sample

Include all the spring application jar for MVC and for sqlite sqlite-jdbc-3.7.2.jar Note :  helloPage.jsp need some amendments to list and iterate the results from controller.  /**  * SqlLite_CURD.java  */ package sample; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; /**  * @author PraveenKumar  *  */ public class SqlLite_CURD { /**  * @param args  */ public static void main(String[] args) { // TODO Auto-generated method stub //getConnection(); // create(); //populateData(); listAllValues(); } public static Connection  getConnection(){ Connection connection=null; try{ Class.forName("org.sqlite.JDBC");  connection=DriverManager.getConnection("jdbc:sqlite:D:/Praveen/sw/SQL_LITE/test.db"); //String sql="SELECT name FROM sqlite_master WHERE type='table' ...

Add current system time to custom date(any date)

Image
if you want to add the current system time with your custom date , use the following sample to do it. you can also customize it your requirement accordingly.  select process_date,  to_date(to_char(process_date,'dd/mm/yyyy')||TO_CHAR(sysdate, 'HH:MI:SS'),'dd/mm/yyyy HH:MI:SS')  from T_BATCH_OPT where    schedule_id=3329 and rownum=1; SELECT to_date('10/12/2014'||TO_CHAR(sysdate, 'HH:MI:SS'),'dd/mm/yyyy HH:MI:SS')  FROM dual;

SQLite CURD function in java

Sample Java prg using SQLite .. CURD operation.  Set up sqlite classpath  and path to ur machine accordingly.  /** * */ package sample; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.Statement; /** * @author PraveenKumar * */ public class SqlLite_CURD { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub //getConnection(); create(); populateData(); listAllValues(); } public static Connection getConnection(){ Connection connection=null; try{ Class.forName("org.sqlite.JDBC"); connection=DriverManager.getConnection(" jdbc:sqlite:D:/Praveen/sw/SQL_LITE/test.db "); //String sql="SELECT name FROM sqlite_master WHERE type='table' ;"; // String sql="SELECT * from test ;"; // PreparedStatement stmt=conn.prepareStatement(sql); // System.out.println(...

Numeric to Roman number conversion

Roman number conversion from numeric to roman. The code seems  bigger but it is simple logic, if you want to try copy paste the code in the appropriate class name and execute the main class..... /**  *  */ package numbers; /**  * @author PraveenKumar  *  */ public class RomanConversionImpl implements IromanConversion{ public String convertRomanNumbers(int number) throws Exception { String romanNumber=""; boolean falg=new ISValidNumber().isValidNumber(number); if(!falg){ romanNumber=romanNumber+NumberRangeConversion.converNumber(number); }else{ throw new Exception("Invalid Number please validate your input!!!"); } NumberRangeConversion.reset(); return romanNumber; } } /**  *   */ package numbers; /**  * @author PraveenKumar  *   */ public class NumberRangeConversion { static String roman = ""; public static String conve...

JUNIT TEST Case Sample for fresher

This is basic test case created using JUNIT. Which will give you basic understanding of Junit testcase . /**  *  */ package test; /**  * @author PraveenKumar  *  */ public class JunitTest { public boolean validatePositivenonZero(int a, int b){ if(a > 0 && b > 0){ return false; } return true; } public int add(int a , int b){ return a+b; } public int multiply(int a, int b){ return a*b ; } public double add(double a, double b){ return a+b; } } /**  *   */ package com.junit.testcase.test; import static org.junit.Assert.*; import junit.framework.Assert; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import test.JunitTest; /**  * @author PraveenKumar  *  */ public class UnitTestCase { private int a; private int b; /** * @throws java.lang.Exception ...

HashMap implementation

How to implement the hashmap without using HashMap class from java collection util package. This is one of the interview question asked from JP Morgan I haven't answer in the following way but i have tried to explain in Datastructure. It would help someone like me .. :) enjoy this can be enhance in more but to make it simple .. import java.util.ArrayList; import java.util.Arrays; import java.util.List; /**  *  */ /**  * @author PraveenKumar  *  */ public class HashMapDS {  /**   * @param args   */  public static void main(String[] args) {     HashMap map=new HashMap();   for(int i=0;i    map.put("a"+i, i+10);   }   System.out.println(""+map.get("a1")+25);   map.display(map);  } } import java.util.ArrayList; import java.util.List; /**  *  */ /**  * @author PraveenKumar  *  */ public class HashMap { ...

AOP Samples

ApplicationContext.xml xml version = "1.0" encoding = "UTF-8" ?> < 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" xsi:schemaLocation = "http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" > < bean id = "bModel" class = "com.sp.sample.aop.BusinessModel" ></ bean > < bean id = "beforeAspect" class = "com.sp.sample.aop.BeforeAspectAdvicer" ></ bean > < bean id = "proxy" class = "org.springframework.aop.framework.ProxyFactoryBean" > < property name = "target" ref = "bModel" ></ property > < property name = "interceptorNames...