[Pljava-dev] Newbie question org.postgresql.pljava.internal.ServerException

stefano bianchi stefano.bianchi at iskranet.net
Fri Jan 5 10:39:53 UTC 2007


Hi everybody,

I'm start in testing using Win Xp Postgres and PLJava.

As my old postgres installation was outdated i make a fresh installation,
incudingt also PLJava using, postgres-8-2-int installer.

Al the installation work well, and I suppose also the test runs good.

Then I start to write my own littlte class, and i "lear" ho pass and receive
data from postgres to the java class.

I got problem when i use jdbc connection. I play with a simple insert
statement, and it seem to work 8 i had received a 1 row result from insert
statement, but I got also an exception, and the record isn't stored in his
table.

Where i'm wrong ??
!!!!!!!!!!!
Sql

SELECT sqlj.remove_jar('SPYATE_jar', false);
SELECT sqlj.install_jar('file:///temp/SPyate.jar', 'SPYATE_jar', false);
SELECT sqlj.set_classpath('public', 'SPYATE_jar');
CREATE OR REPLACE FUNCTION usertest()
RETURNS int4 as
'net.gesttec.gbedidi.storedP.yate.UsrReg.test'
LANGUAGE 'java' VOLATILE;
select * from usertest();
ERROR: 05 gen 07 11:12:45 net.gesttec.gbedidi.storedP.yate.UsrReg
SQLException ::: org.postgresql.pljava.internal.ServerException: 05 gen 07
11:12:45 net.gesttec.gbedidi.storedP.yate.UsrReg TEST result row:1

Stato SQL: XX000
!!!!!!!!!!!!!!!!!!!!!!!!!!!
Java
package net.gesttec.gbedidi.storedP.yate;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Logger;

//import java.sql.ResultSet;

public class UsrReg
{
	public static void log(String str)
	{
		Logger.getAnonymousLogger().severe(str);
	}

	public final static int test() throws SQLException
	{
		Connection conn = DriverManager
				.getConnection("jdbc:default:connection");
		if (conn == null)
		{
			log("ERROR invalid connection !!!");
		} else
		{
			try
			{
				PreparedStatement insert = conn
						.prepareStatement("insert
into public.users (username) values('pippo')");
				log("TEST result row:" +
insert.executeUpdate());
//				insert.close();
			} catch (SQLException e)
			{
				log("SQLException ::: " + e + "\n");
			}
		}
		return 1;
	}
}

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1
Any help is welcome.

Thanks in advace


Stefano Bianchi
mailto:stefano.bianchi at iskranet.net          
Tl +393347516311 o-o Tl +39 348 26 53 362 
Fx +39 02 700 438 539







More information about the Pljava-dev mailing list