agora inbox for pgsql-sql@postgresql.org
help / color / mirror / Atom feedFrom: Eugene Yin <eugeneymail@ymail.com>
To: Andreas Joseph Krogh <andreas@visena.com>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: BLOBs
Date: Mon, 11 Jan 2016 15:37:50 +0000 (UTC)
Message-ID: <2023667230.3407381.1452526670272.JavaMail.yahoo@mail.yahoo.com> (raw)
In-Reply-To: <VisenaEmail.a.18468a0d72ecb60d.15230235d69@tc7-visena>
References: <VisenaEmail.a.18468a0d72ecb60d.15230235d69@tc7-visena>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>
QUOTE:
Maven-config:<properties>
<version.pgjdbc-ng>0.6</version.pgjdbc-ng>
</properties>
<dependency>
<groupId>com.impossibl.pgjdbc-ng</groupId>
<artifactId>pgjdbc-ng</artifactId>
<version>${version.pgjdbc-ng}</version>
<classifier>complete</classifier>
</dependency>
I do not use Maven.
I use web.xml and standalone-ha.xml of JBoss AS 7.1.1 to configure the JDBC, such as
[web.xml]
<resource-ref> <description>Resourcereference to my database</description> <res-ref-name>jdbc/web</res-ref-name> <res-type>javax.sql.DataSource</res-type> <res-auth>Application</res-auth> <res-sharing-scope>Shareable</res-sharing-scope> </resource-ref>
[standalone-ha.xml]
<datasource jta="false" jndi-name="java:/jdbc/web" pool-name="OracleDS" enabled="true" use-ccm="false"> <connection-url>jdbc:oracle:thin:@192.168.1.20:1521:deepy</connection-url> <driver-class>oracle.jdbc.OracleDriver</driver-class> <driver>OracleJDBCDriver</driver> <security> <security-domain>mysecuritydomain</security-domain> </security> <validation> <validate-on-match>false</validate-on-match> <background-validation>false</background-validation> </validation> <statement> <share-prepared-statements>false</share-prepared-statements> </statement> </datasource>
What corresponding changes I need to make to use the Postgres?
Thanks
Eugene
On Monday, January 11, 2016 2:10 AM, Andreas Joseph Krogh <andreas@visena.com> wrote:
På mandag 11. januar 2016 kl. 01:37:52, skrev Eugene Yin <eugeneymail@ymail.com>:
I use the BLOB in an Oracle table to store IMG and document files. Now for Postgres(9.4.5), I have two options, i.e., BYTEA or OID. With consideration of passing the params (SAVING) from the Java side as follows: DiskFileItemDeepy file = myFile; InputStream is = null; long fileSize = 0; if (file != null && file.getFileSize() > 0){ is = file.getInputStream(); fileSize = file.getFileSize(); call.setBinaryStream(1, (InputStream)is, (long)fileSize);}...call.execute(); //When retrieve the data use: java.sql.Blob blob = (Blob) resultSet.getBlob(tableColumnName); For the purpose mentioned above, which Postgres data type is a better candidate for replacement the BLOB, BYTEA or OID?
From my experience, always use OID for BLOBs, and use the pgjdbc-ng JDBC-driver here: https://github.com/impossibl/pgjdbc-ng Maven-config:<properties;
<version.pgjdbc-ng>0.6</version.pgjdbc-ng>
</properties>
<dependency>
<groupId>com.impossibl.pgjdbc-ng</groupId>
<artifactId>pgjdbc-ng</artifactId>
<version>${version.pgjdbc-ng}</version>
<classifier>complete</classifier>
</dependency>
In the connection-URL use blobtype=oid:datasource.url=jdbc:pgsql://localhost:5432/andreak?blob.type=oid
This is the only (as I know of) combination which lets you work with true streams all the way down to PG. This way you can work with very large images/movies/documents without sacrificing memory.The official JDBC-driver for PG doesn't support BLOBs proparly, no getBlob/createBlob (among other things, like custom type mappings). --Andreas Joseph KroghCTO / Partner - Visena ASMobile: +47 909 56 963andreas@visena.comwww.visena.com
=
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql
view thread (20+ messages) latest in thread
Message-ID: <2023667230.3407381.1452526670272.JavaMail.yahoo@mail.yahoo.com>
Permalink: ../2023667230.3407381.1452526670272.JavaMail.yahoo@mail.yahoo.com/
Also on: postgresql.org/message-id/2023667230.3407381.1452526670272.JavaMail.yahoo@mail.yahoo.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: pgsql-sql@postgresql.org
Cc: eugeneymail@ymail.com, andreas@visena.com
Subject: Re: BLOBs
In-Reply-To: <2023667230.3407381.1452526670272.JavaMail.yahoo@mail.yahoo.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox