Skip to content

Instantly share code, notes, and snippets.

View aziz781's full-sized avatar

Abdul Aziz (A575072) aziz781

View GitHub Profile
@aziz781
aziz781 / gist:1336506
Created November 3, 2011 13:43
Spring JMS sample configuration applicationContext-jms.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:amq="http://activemq.apache.org/schema/core"
@aziz781
aziz781 / gist:1336502
Created November 3, 2011 13:40
Spring quartz sample configuration applicationContext-quartz.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:amq="http://activemq.apache.org/schema/core"
@aziz781
aziz781 / gist:1336493
Created November 3, 2011 13:37
Spring framework sample applicationContext.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch="http://www.springframework.org/schema/batch"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:amq="http://activemq.apache.org/schema/core"
@aziz781
aziz781 / gist:1336488
Created November 3, 2011 13:34
Java sample persistence.xml with JNDI JTA Data source and Hibernate configuration
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd">
<persistence-unit name="MyAppUnit" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<jta-data-source>java:/myAppDS</jta-data-source>
<!-- Package: uk.co.example.domain -->
@aziz781
aziz781 / gist:1336483
Created November 3, 2011 13:30
Java Spring Batch: Running a Spring Batch Job
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecution;
import org.springframework.batch.core.JobExecutionException;
@aziz781
aziz781 / gist:1336475
Created November 3, 2011 13:27
Running a Spring Batch Job in The Spring framework Application
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.JobExecutionContext;
import org.springframework.batch.core.JobExecutionException;
import org.springframework.batch.core.JobParameters;
import org.springframework.batch.core.JobParametersBuilder;
import org.springframework.batch.core.configuration.JobLocator;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.scheduling.quartz.QuartzJobBean;
@aziz781
aziz781 / gist:1336459
Created November 3, 2011 13:21
Java, Spring JDBC : How to call Stored Procedure with IN and OUT parameters
import java.util.Date;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.object.StoredProcedure;
public class MyStoredProcedure extends StoredProcedure{
public MyStoredProcedure(String procedureName,DataSource dataSource) {
super(new JdbcTemplate(dataSource), procedureName);
@aziz781
aziz781 / gist:1336420
Created November 3, 2011 13:01
java: Hibernate String How to execute named query
public boolean dealerExists(String agentNumber) {
return getSessionFactory().getCurrentSession()
.getNamedQuery("myapp.namedquery").setParameter(0, agentNumber)
.list().get(0) != null;
}
@aziz781
aziz781 / gist:1336418
Created November 3, 2011 12:58
java: how to Call Stored Procedure and DB connection from JNDI
public static void processData(int param1, int param2)
{
CallableStatement cs=null;
Connection conn=null;
try{
// get JNDI JDBC connection
InitialContext ctxt = new InitialContext();
DataSource ds = (DataSource) ctxt.lookup("java:/myAppDS");
@aziz781
aziz781 / gist:1336413
Created November 3, 2011 12:53
Convert Java Throwable exception stack trace into String
public static String getStackTrace(Throwable aThrowable) {
final Writer result = new StringWriter();
final PrintWriter printWriter = new PrintWriter(result);
aThrowable.printStackTrace(printWriter);
return result.toString();
}