Thread: SQLException: ERROR: oidin: when loading GIF file

SQLException: ERROR: oidin: when loading GIF file

From
"Craig Jarman"
Date:
Hi
 
Has anyone run into difficulties uploading a blob to postgres?
 
I am unable to load an image file into postgres using the jdbc7.1-1.3.jar driver.
 
Application server runs on NT, Postgres on Linux 7.1
 
Error received:
 
java.sql.SQLException: ERROR:  oidin: error in "GIF89a1.....
 
Code:
 
Class.forName("org.postgresql.Driver");
Connection conn = DriverManager.getConnection("jdbc:postgresql://192.168.0.50:5432/ezweb","administrator","password");
File file = new File("d:/Temp/testimage.gif");
FileInputStream fis = new FileInputStream(file);
 
PreparedStatement ps = conn.prepareStatement("INSERT INTO IMAGES VALUES (?, ?)");
ps.setString(1, file.getName());
            
Long  length = new Long(file.length());
ps.setBinaryStream(2, fis,length.intValue());
ps.executeUpdate();
ps.close();
fis.close();
 
Any pointers to what "oiden" refers to would be much appreciated.
 
______________________________
 
Craig Jarman
Source IT
Ph: 612 9974 1480
Fx: 612 9974 1280
cjarman@source.com.au
______________________________

Re: SQLException: ERROR: oidin: when loading GIF file

From
Bruce Momjian
Date:
I recommend you get our newer jdbc driver from jdbc.postgresql.org.

---------------------------------------------------------------------------

> Hi
>
> Has anyone run into difficulties uploading a blob to postgres?
>
> I am unable to load an image file into postgres using the jdbc7.1-1.3.jar driver.
>
> Application server runs on NT, Postgres on Linux 7.1
>
> Error received:
>
> java.sql.SQLException: ERROR:  oidin: error in "GIF89a1.....
>
> Code:
>
> Class.forName("org.postgresql.Driver");
> Connection conn =
DriverManager.getConnection("jdbc:postgresql://192.168.0.50:5432/ezweb","administrator","password");
> File file = new File("d:/Temp/testimage.gif");
> FileInputStream fis = new FileInputStream(file);
>
> PreparedStatement ps = conn.prepareStatement("INSERT INTO IMAGES VALUES (?, ?)");
> ps.setString(1, file.getName());
>
> Long  length = new Long(file.length());
> ps.setBinaryStream(2, fis,length.intValue());
> ps.executeUpdate();
> ps.close();
> fis.close();
>
> Any pointers to what "oiden" refers to would be much appreciated.
>
> ______________________________
>
> Craig Jarman
> Source IT
> Ph: 612 9974 1480
> Fx: 612 9974 1280
> cjarman@source.com.au
> ______________________________

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: SQLException: ERROR: oidin: when loading GIF file

From
Bruce Momjian
Date:
I should have added that there were known problems with BLOBS and the
jdbc that shipped with 7.1.3, and the new driver should be fine.

---------------------------------------------------------------------------

> Hi
>
> Has anyone run into difficulties uploading a blob to postgres?
>
> I am unable to load an image file into postgres using the jdbc7.1-1.3.jar driver.
>
> Application server runs on NT, Postgres on Linux 7.1
>
> Error received:
>
> java.sql.SQLException: ERROR:  oidin: error in "GIF89a1.....
>
> Code:
>
> Class.forName("org.postgresql.Driver");
> Connection conn =
DriverManager.getConnection("jdbc:postgresql://192.168.0.50:5432/ezweb","administrator","password");
> File file = new File("d:/Temp/testimage.gif");
> FileInputStream fis = new FileInputStream(file);
>
> PreparedStatement ps = conn.prepareStatement("INSERT INTO IMAGES VALUES (?, ?)");
> ps.setString(1, file.getName());
>
> Long  length = new Long(file.length());
> ps.setBinaryStream(2, fis,length.intValue());
> ps.executeUpdate();
> ps.close();
> fis.close();
>
> Any pointers to what "oiden" refers to would be much appreciated.
>
> ______________________________
>
> Craig Jarman
> Source IT
> Ph: 612 9974 1480
> Fx: 612 9974 1280
> cjarman@source.com.au
> ______________________________

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: SQLException: ERROR: oidin: when loading GIF file

From
Barry Lind
Date:
Craig,

oidin is the input function for a column of datatype oid.  My guess as
to your problem is that your table definition is incorrect.  What does
your images table look like?

thanks,
--Barry


Craig Jarman wrote:

> Hi
>
>
>
> Has anyone run into difficulties uploading a blob to postgres?
>
>
>
> I am unable to load an image file into postgres using the
> jdbc7.1-1.3.jar driver.
>
>
>
> Application server runs on NT, Postgres on Linux 7.1
>
>
>
> Error received:
>
>
>
> java.sql.SQLException: ERROR:  oidin: error in "GIF89a1.....
>
>
>
> Code:
>
>
>
> Class.forName("org.postgresql.Driver");
> Connection conn =
> DriverManager.getConnection("jdbc:postgresql://192.168.0.50:5432/ezweb","administrator","password");
>
> File file = new File("d:/Temp/testimage.gif");
> FileInputStream fis = new FileInputStream(file);
>
>
>
> PreparedStatement ps = conn.prepareStatement("INSERT INTO IMAGES VALUES
> (?, ?)");
> ps.setString(1, file.getName());
>
> Long  length = new Long(file.length());
>
> ps.setBinaryStream(2, fis,length.intValue());
> ps.executeUpdate();
> ps.close();
> fis.close();
>
>
>
> Any pointers to what "oiden" refers to would be much appreciated.
>
>
>
> ______________________________
>
>
>
> Craig Jarman
> Source IT
> Ph: 612 9974 1480
> Fx: 612 9974 1280
> cjarman@source.com.au <mailto:cjarman@source.com.au>
> ______________________________
>