pg.ddx.io  pljava-dev@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Subject: [Pljava-dev] null pointer exception in pl/java jdbc driver
Date: Thu, 24 May 2012 09:07:43 +0000
Message-ID: <oby4pb.x5oby4pb.wr42.7xr4.gnus@asuka.myrkraverk.com> (raw)
In-Reply-To: <C35FDD5FDF7E584991A6AAF8F1A8425F0226AD3A@ltischx01.lti.int>
References: <C35FDD5FDF7E584991A6AAF8F1A8425F0226AD3A@ltischx01.lti.int>

"Welty, Richard" <rwelty at ltionline.com> writes:

> i'm having trouble chasing down what may be close to the last bug in
> my pl/ java code, a null pointer when executing an update. are there
> restrictions on what i can do inside a function with this jdbc driver? 
> at this point, the code has successfully done a select, found the rows
> it wants and issued an http request to a solr search engine; now it
> needs to delete the rows that triggered the successful update:
>
> the method:

The following code works for me.  Can you give us the steps you are
taking?

package com2ndQuadrant.pljava;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.SQLException;

import java.util.List;
import java.util.LinkedList;

import java.util.logging.Logger;

public class Update
{
	public static void delete( Connection c,
				   String key,
				   List< Integer > ids )
		throws SQLException
	{
		String s = ids.toString();
		s = s.substring( 1, s.length() - 1 );

		Logger l = Logger.getAnonymousLogger();

		l.fine( s );

		String r = "delete from t where key = '" 
			+ key
			+ "' and id in ( " + s + " ) ";

		l.fine( r );

		Statement stm = c.createStatement();

		stm.execute( r );
	}

	public static void doStuff( String key )
		throws SQLException
	{
		Connection c = DriverManager.getConnection
			( "jdbc:default:connection" );

		List< Integer > l = new LinkedList< Integer >();

		l.add( 3 );
		l.add( 5 );
		l.add( 7 );

		delete( c, key, l );
	}
}


-- 
   Johann Oskarsson                http://www.2ndquadrant.com/    |[]
   PostgreSQL Development, 24x7 Support, Training and Services  --+--
                                                                  |
   Blog: http://my.opera.com/myrkraverk/blog/




view thread (11+ messages)  latest in thread

Message-ID: <oby4pb.x5oby4pb.wr42.7xr4.gnus@asuka.myrkraverk.com>
Permalink:  ../oby4pb.x5oby4pb.wr42.7xr4.gnus@asuka.myrkraverk.com/
Also on:    postgresql.org/message-id/oby4pb.x5oby4pb.wr42.7xr4.gnus@asuka.myrkraverk.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pljava-dev@postgresql.org
  Subject: Re: [Pljava-dev] null pointer exception in pl/java jdbc driver
  In-Reply-To: <oby4pb.x5oby4pb.wr42.7xr4.gnus@asuka.myrkraverk.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox