Archive for the ‘quick tips’ Category

The Processing Instruction Target Matching “[xX][mM][lL]” is Not Allowed

Friday, June 24th, 2011

Background

When parsing XML you receive the following error:

...The Processing Instruction Target Matching "[xX][mM][lL]" is Not Allowed...

Solution

The chances are you have some sort of whitespace (or control character) infront of your XML declaration:

..<?xml version="1.0" encoding="utf-8"?>

It may even be that you have more than one XML declaration in the document..!

Tags:
Posted in quick tips | No Comments »

Read a File as String with Java

Thursday, June 16th, 2011

Introduction

I’m always Googling for a way to do this. This seems to be the best “idiomatic” solution I’ve found. So without further ado…

Example

public String readFile(String path) throws IOException {
    FileInputStream stream = new FileInputStream(new File(path));
    try{
        FileChannel fc = stream.getChannel();
        MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
        return Charset.defaultCharset().decode(bb).toString();
    }
    finally {
        stream.close();
    }
}

Tags:
Posted in Development, How to's, quick tips | No Comments »

View Source of Oracle Trigger

Wednesday, May 11th, 2011

select trigger_body from user_triggers where trigger_name = 'XXXXX'

Tags: ,
Posted in quick tips | No Comments »

DB2’s equivalent of Oracle’s “dual”

Wednesday, February 16th, 2011

This is really a quick example of DB2’s equivalent of Oracle’s “dual”

Get current date/time in DB2

select current date from sysibm.sysdummy1 

Tags:
Posted in Development, quick tips | No Comments »

Access a Spring Bean from within a Servlet

Tuesday, September 21st, 2010

ApplicationContext context =
    WebApplicationContextUtils.getWebApplicationContext(getServletContext());
MyService service = (MyService) context.getBean("serviceBeanName");

Tags: ,
Posted in Development, quick tips | No Comments »