pg.ddx.io pgsql-jdbc@postgresql.org mailing list archive
help / color / mirror / Atom feedBinary transfer not working
3+ messages / 2 participants
[nested] [flat]
* Binary transfer not working
@ 2015-04-06 14:38 Alex Ignatov <alexign@gmail.com>
0 siblings, 2 replies; 3+ messages in thread
From: Alex Ignatov @ 2015-04-06 14:38 UTC (permalink / raw)
To: pgsql-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) {
}
}
}
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Binary transfer not working
@ 2015-04-07 10:49 Dave Cramer <pg@fastcrypt.com>
parent: Alex Ignatov <alexign@gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Dave Cramer @ 2015-04-07 10:49 UTC (permalink / raw)
To: Alex Ignatov <alexign@gmail.com>; +Cc: pgsql-jdbc
Can you show me the definition of the table please ?
Dave Cramer
dave.cramer(at)credativ(dot)ca
http://www.credativ.ca
On 6 April 2015 at 10:38, Alex Ignatov <alexign@gmail.com> wrote:
> 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) {
> }
>
> }
> }
>
>
>
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Binary transfer not working
@ 2015-04-07 21:15 Dave Cramer <pg@fastcrypt.com>
parent: Alex Ignatov <alexign@gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Dave Cramer @ 2015-04-07 21:15 UTC (permalink / raw)
To: Alex Ignatov <alexign@gmail.com>; +Cc: pgsql-jdbc
Alex,
You are not doing anything wrong. Turns out forceBinaryTransfer doesn't
work because:
public void setPrepareThreshold(int newThreshold) throws SQLException {
checkClosed();
if (newThreshold < 0) {
forceBinaryTransfers = true;
newThreshold = 1;
}
else
*forceBinaryTransfers = false*;
this.m_prepareThreshold = newThreshold;
}
I'm trying to figure out if we should ever reset forceBinaryTransfers
I removed the line in italics above in the snapshot
https://oss.sonatype.org/content/repositories/snapshots/org/postgresql/postgresql/9.4-1201-jdbc41-SN...
Let me know if that works
Dave Cramer
dave.cramer(at)credativ(dot)ca
http://www.credativ.ca
On 6 April 2015 at 10:38, Alex Ignatov <alexign@gmail.com> wrote:
> 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) {
> }
>
> }
> }
>
>
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2015-04-07 21:15 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-04-06 14:38 Binary transfer not working Alex Ignatov <alexign@gmail.com>
2015-04-07 10:49 ` Dave Cramer <pg@fastcrypt.com>
2015-04-07 21:15 ` Dave Cramer <pg@fastcrypt.com>
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