Connection.setBytes() - Mailing list pgsql-interfaces

From Matt Fair
Subject Connection.setBytes()
Date
Msg-id 3974A420.265E7650@netasol.com
Whole thread Raw
Responses Re: Connection.setBytes()
List pgsql-interfaces
I want to set an array of bytes to a prepared statement, but it throws a
null pointer exception.  Here is my code:
       String description = new String(".........4000 Bytes.......");       PreparedStatement pstmt =
con.prepareStatement("INSERTINTO
 
mytable (str) VALUES (?)");       pstmt.setBytes(1,description.getBytes());  //Line 65, throws
NullPointerException here       pstmt.executeUpdate();       pstmt.close();

Exception in thread "main" java.lang.NullPointerExceptionat org.postgresql.Connection.ExecSQL(Connection.java:312)at
org.postgresql.jdbc2.Statement.execute(Statement.java:273)at
org.postgresql.jdbc2.Statement.executeQuery(Statement.java:54)at
org.postgresql.largeobject.LargeObjectManager.<init>(LargeObjectManager.java:106)
at org.postgresql.Connection.getLargeObjectAPI(Connection.java:561)at
org.postgresql.jdbc2.PreparedStatement.setBytes(PreparedStatement.java:297)
==== >at PsqlConsole.prompt(PsqlConsole.java:65) <====at PsqlConsole.main(PsqlConsole.java:87)

It throws it when I call setBytes(), I don't know what the problem is.
I got the source of setBytes and put it in my code where I have
setBytes().  It was throwing a null pointer when it was calling
getLargeObjectAPI().
Has anyone else had this error?
Thanks
Matt Fair



pgsql-interfaces by date:

Previous
From: Þórhallur Hálfdánarson
Date:
Subject: ResultSetMetaData problems (getColumnType() and -TypeName)
Next
From: John Thorhauer
Date:
Subject: jdbc how to get SERIAL