Integration Bus – JDBC – SQLCODE=-805, SQLSTATE=51002

If you find you are hitting this SQL error when using Integration Bus with JDBC you are probably not closing off everything properly.

As documented in the Knowledge Centre, IIB maintains a connection for a given application until it idles out (default 60 seconds). As a result:

  • DO NOT close the actual connection. If you do this then IIB will have to create new connections every time which is very time and resource consuming.
  • DO  close off all statements or result sets etc.


//Connect to Stock database
Connection conn = getJDBCType4Connection(“DB_2”,JDBC_TransactionType.MB_TRANSACTION_AUTO);
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);

//Check current stock level
myQuery = “SELECT STOCK FROM MQPERF.STOCK WHERE ITEM = ‘” + Description + “‘”;
resultSet = stmt.executeQuery(myQuery);;
int itemStock = Integer.parseInt(resultSet.getString(1));

xp = new MbXPath(“/Body/wss:SaleRequest/SaleEnvelope/SaleList/Invoice/Item/Quantity”);
xp.addNamespacePrefix(“wss”, “”);
int orderQuantity= Integer.parseInt(((MbElement) ((List<?>)inAssembly.getMessage().evaluateXPath(xp)).get(0)).getValueAsString());
int newStock = itemStock – orderQuantity;
CallableStatement callableStatement = conn.prepareCall(“{call update_stock(?,?)}”);
callableStatement.setInt(1, newStock);
callableStatement.setString(2, Description);
progress = “CompletedUpdate”;

DHCP Failing – Error 5: Access is denied starting Diagnostics Policy Service

If the DHCP stops working on your machine, this might be due to the Diagnostics Policy Service not running. If you try and start it manually you get the following error “Error 5: Access is denied ”
To fix this is simple if you know how. Run the following command from an elevated command prompt

net localgroup administrators localservice /add
net localgroup administrators networkservice /add

Then reboot and you should have DHCP back and running

Windows 7 – Windows Update error 8007000D

The following fixed this for me

8007000D – Error_invalid_data. Corruption in the SoftwareDistribution folder. Please rename %windir%/Softwaredistribution folder.

To rename the Windows Update temporary SoftwareDistribution directory follow these steps:

1. Start an administrative command prompt.
2. Run the following commands hitting enter after each line:

  • Net stop wuauserv
  • cd %systemroot%
  • Ren SoftwareDistribution SoftwareDistribution.old
  • Net start wuauserv

3. Reboot
4. Try to install updates again

Hendy Bodyshop – How many attempts does it take??

We had the unfortunate to need to have our virtually new Mazda 3 repaired after an accident in which it sustained some quite bad damage

When we got the car we were told all about the Mazda Accident Aftercare and so thought this would be the time to put it into action. Our insurer wanted to use an unknown local bodyshop but we let Mazda Accident Aftercare handle the issue and the car was transported the next day to Hendy Bodyshop in Segensworth (off to a good start). We expected that as this was going to a Mazda Approved that used Mazda parts etc the car would come back looking like new.

Within a few days we were told the damage and that the job had been approved so they had started work.  (again – all good)

Attempt 1

The car was then delivered back approx 1 month later. It was delivered to my wifes work address but unfortunately it was raining so she could not perform a full inspection.  That evening it dried up and then when I got home I had a good look over it.

What can I say – A fairly poor job. It looked like the job bad been rushed and corners cut. So what was wrong.

Overall the colour match was very poor. This could be most seen on the rear door shuts where they had obviously taped up just inside the lip, sprayed the new (wrong colour) and then removed the tap. This left a really hash line and towards the top when removing the tape lifted some of the paint. This left a very rough proud section. How this could get through Quality Control is beyond belief.

Unfortunately Photos don’t really justify how bad it looked in real life

This line went all the way the way from below the rear window to the front of the back door.

After noticing this we went on to see a number of things – many just careless such as where they had not properly removed trim pieces and then paint had got onto them and dried.

More tape marks on the edge of the bonnet – rough to touch so again no ideas how it got through “Quality Control”

We also noticed some other areas that had not been fully painted like the bottom front lip of the rear door, there were paint finger marks on the rubber trim.

Just as we thought we had seen everything a quick check on the arch then highlighted further sloppy work. Here you can see where not enough paint has been put down (the bluey looking line just in from the lip)

Then below this they had obviously sprayed some sort of back under-seal on the inner arch but not tapped off the painted panels resulting in splatter marks all over the paintwork

In all a list of 8 areas were highlighted that needing fixing. When we mentioned that we were not happy Hendy were good at sending out a replacement car and picking up the Mazda again

Attempt 2

Just under a week after having the car picked up to rectify the issues we went to pickup the car. We decided it was best to go to the bodyshop so that if we were not happy we could just leave it there…just as well. The day before delivery was spent waiting as the car was “waiting to be cleaned”

Overall it looked good at a distance again but when you went close there were some things still not right.

On the rear door shuts they had done a good job of sanding down the proud paint and blending in the colour so there was no noticeable line BUT they they stopped at the back bottom corner of the shut even through it was obvious there was a clear line all along the bottom of the door shut. I just could not understand how they could not have seen this.

I also noticed more tape marks just under the rear small window, along with along the top of the window where lots of paint had been put down it caused a join between the painted panel and the glass (which will be fun to try and fix). Some more very small tape marks were found where they had not fully taped off the rear bumper.

One last bit was not done. The bottom lip of the door had still not been done “I was not sure which bit that was” why they didn’t just pick up the phone and ask I have no idea.

It was obvious they had done quite a bit of colour sanding as there was compound marks all over the rear. The car had certainly not been cleaned very well. The inside of the rear door was covered in sanding dust.

So once again the car was left and we took away the loan car again. The following day we were planning to drive to Liverpool to spend the long weekend there. Via email we made sure that the bodyshop knew this and we needed the car by 12 if it was going to be done that day. We did clarify we would rather it done properly than rushed for the deadline. We were told that we would be told by around 11 whether it would get done in time……….you guessed it nothing till 1:30 to then say the car is ready!.  As there was not enough time to collect the car we put the 500 mile trip to Liverpool on the loan car.

Attempt 3

Thank-fully it was a dry day when we went to pick the car up. They had fixed the major issues we had pointed out but had not bothered with some of the others such as the paint all around the door sill piece, also where there was tape marks on the bumper where they had not taped it up correctly.

I also noticed that they had used way too much lacquer when doing the door shuts as you could feel the run but it had got to the point we just wanted the car back. It was good to know that the car had been valeted…..well if thats what they call valet it only matches up to the quality of workmanship we have seen so far

Couple of pictures to give you an idea of their ‘valet’

Just a little bit of sanding dust


So – Maybe we should just have let Admiral sort it for us as the Mazda approved Hendy bodyshop experience was very poor, very sloppy work. They obviously had the skill to do the job properly if they wanted but they were cutting too many corners. Something I would not expect for expensive insurance job.

So far its been a pretty poor experience of the Hendy Group company after the poor state the car was delivered in when we bought it, now the bodyshop. Will we give their service dept a go – lets wait and see.

Mosquitto 1.0 python changes

Looks like there have been some changes to the Mosquitto v1.0.1 python libraries. So far only hit the one but it was quite a major one. The connect method has been changed. If you try and run your code you will get

Traceback (most recent call last):
File "", line 13, in <module>
mqttc.connect(broker, port, 60, True)
TypeError: connect() takes at most 4 arguments (5 given)

In 1.0 the connect function changed from:
def connect(self, hostname="localhost", port=1883, keepalive=60, clean_session=True):
def connect(self, host, port=1883, keepalive=60):

So all it needed was to remove the true flag from the connect statement and then the script worked.

Installing Mosquitto 1.0.1 in Raspbian on Raspberry Pi

Mosquito have just released their 1.0 release..well actually its already 1.01 🙂

Currently the Raspbian repositories don’t seem to have it but its nice and easy to get working

tar -zxvf mosquitto-1.0.1.tar.gz
cd mosquitto-1.0.1
sudo make install
sudo ldconfig

Jobs a goodun. It can be checked by running “moqsuitto -v”. If you are already running a previous version you will want to restart the service using “service mosquitto restart”

Using node.js WebSockets to get live MQTT updates

To keep some of my pages up to date with the live sensor data I am using websockets to get MQTT publications.

On the server there are two parts. A Python script which is monitoring a serial port for data and then publishing it accordingly. Information about this can be found at  XRF Temperature Sensor -> XRF Slice of Pi

The second part on the server is a node.js application which is runs a websocket server. For further information about installing Node.js take a look at Install Node.js v0.8.2 on Raspbian The server application creates an mqtt subscription for every connection, it subscribes to the topic according to the url that the client has come in on i.e. will cause a subscription on MyTopic.

Node.js server code

#!/usr/bin/env node
var util   = require('util');
sys = require("sys");
url = require("url");
var WebSocketServer = require('websocket').server;
var http = require('http');
spawn = require('child_process').spawn;

var args = { /* defaults */
    port: '8000',
    debug: 'true'
/* Parse command line options */
var pattern = /^--(.*?)(?:=(.*))?$/;
process.argv.forEach(function(value) {
    var match = pattern.exec(value);
    if (match) {
        args[match[1]] = match[2] ? match[2] : true;
var port = parseInt(args.port, 10);
var debug = (args.debug == 'true');

var server = http.createServer(function(request, response) {
    console.log((new Date()) + ' Received request for ' + request.url);
server.listen(port, function() {
    console.log((new Date()) + ' Server is listening on port ' + port);

wsServer = new WebSocketServer({
    httpServer: server,
    // You should not use autoAcceptConnections for production
    // applications, as it defeats all standard cross-origin protection
    // facilities built into the protocol and the browser.  You should
    // *always* verify the connection's origin and decide whether or not
    // to accept it.
    autoAcceptConnections: false

function originIsAllowed(origin) {
  // put logic here to detect whether the specified origin is allowed.
  return true;

wsServer.on('request', function(request) {
    if (!originIsAllowed(request.origin)) {
      // Make sure we only accept requests from an allowed origin
      console.log((new Date()) + ' Connection from origin ' + request.origin + ' rejected.');
    var myProcs=new Array();

    var connection = request.accept('currentcostdata', request.origin);
    console.log((new Date()) + " connection accepted from " + connection.remoteAddress + " via " + request.origin);
    var topicString = request.resource.substring(1);
    console.log((new Date()) + ' Connection Topic: ' + topicString);
    var mosquittopid = request.key;

	console.log((new Date()) + ' Connection ID: ' + mosquittopid);
	mosq = spawn('mosquitto_sub',['-t',topicString]);
	console.log((new Date()) + 'PID of mosquitto_sub for ' + topicString + ' ConID: ' + mosquittopid + ' is ';
	myProcs[mosquittopid] =;

	mosq.stdout.on('data', function (data) {
		console.log((new Date()) + 'Topic: ' + topicString + ' - ' + data);

    connection.on('message', function(message) {
        if (message.type === 'utf8') {
            console.log('Received Message: ' + message.utf8Data);

    connection.on('close', function(reasonCode, description) {
		//console.log((new Date()) + ' Peer ' + connection.remoteAddress + ' disconnected.');
		console.log((new Date()) + ' ' + mosquittopid + ' disconnected');
		console.log((new Date()) + ' ' + topicString + ' Closed: pid: ' + myProcs[mosquittopid] + '.');
		delete myProcs[mosquittopid];

On the client side there is some JavaScript which opens the websockets connection to the server and then listens for updates and acts accoridingly

<script type="text/javascript">// <![CDATA[
		$(document).ready(function() {
			/* Define handler for websocket debug information*/
			function debug(str) {


			function rtrim(str) {
				return str.replace(/\s+$/,"");
			/* Create a websocket connection */
			ws = new WebSocket("ws://myip:8000/CurrentCostTemp","currentcostdata");
			/* Define websocket handlers */
			ws.onmessage = function(evt) {
				var data = rtrim(;
				var temptitle = data +'\u00B0C';
				debug('Temp - ' + temptitle);
			ws.onclose = function() {
				debug("socket closed");
			ws.onopen = function() {

// ]]></script>