pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alex Ignatov <alexign@gmail.com>
To: pgsql-jdbc@postgresql.org
Subject: Binary transfer not working
Date: Mon, 06 Apr 2015 17:38:16 +0300
Message-ID: <55229A58.3080201@gmail.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-jdbc>

Hello!
Im testing jdbc binary transfer mode but i can't make it works as it 
should.
Network packet dump always shows me that for example "dtrntran" 
TIMESTAMP column is transfering in text and not in binary representation 
as it should.
Debug log shows me that binary mode is on, but regardless 
org.postgresql.forceBinary=false/true it is always text.
What am i doing wrong?
jdbc version -  postgresql-9.4-1201.jdbc4.jar
postgresql version - 9.4.1
This is my test code. javac vm arguments is 
-Dorg.postgresql.forceBinary=true

import java.sql.Connection;
import java.sql.Driver;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Properties;
import java.sql.Statement;
import java.sql.Timestamp;

public class TestMe {
     private static java.sql.Timestamp getCurrentTimeStamp() {

         java.util.Date today = new java.util.Date();
         return new java.sql.Timestamp(today.getTime());

     }

     public static void main(String[] args) throws SQLException {

         String url = "jdbc:postgresql://thunder:5432/test";
         Connection conn = null;
org.postgresql.Driver.setLogLevel(org.postgresql.Driver.DEBUG);

         Properties connectionProps = new Properties();
         connectionProps.put("user", "***");
         connectionProps.put("password", "***");
         connectionProps.put("loglevel", "2");
         conn = DriverManager.getConnection(url, connectionProps);
         select(conn);
     }

     private static void select(Connection conn) {
         try {
             PreparedStatement fs = conn.prepareStatement("SELECT 
dtrntran FROM trn order by itrnnum limit 1");
             ResultSet rs = fs.executeQuery();
             for (int i = 0; i < 1; i++) {
                 rs.next();
             }
             rs.close();
             System.out.println("org.postgresql.forceBinary= "
                     + Boolean.getBoolean("org.postgresql.forceBinary"));
         } catch (SQLException e) {
         }

     }
}

view thread (3+ messages)  latest in thread

Message-ID: <55229A58.3080201@gmail.com>
Permalink:  ../55229A58.3080201@gmail.com/
Also on:    postgresql.org/message-id/55229A58.3080201@gmail.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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: alexign@gmail.com
  Subject: Re: Binary transfer not working
  In-Reply-To: <55229A58.3080201@gmail.com>
  References: <55229A58.3080201@gmail.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