import java.sql.*; import java.io.ByteArrayInputStream; public class PrintQuery { public static void main(String args[]) throws Exception { Class.forName("org.postgresql.Driver"); Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/jurka", "jurka", ""); PreparedStatement ps = conn.prepareStatement("SELECT ?"); ps.setString(1, "NULL"); System.out.println(ps.toString()); ps.setString(1, "a\\b"); System.out.println(ps.toString()); byte data[] = new String("data").getBytes("US-ASCII"); ByteArrayInputStream bais = new ByteArrayInputStream(data); ps.setBinaryStream(1, bais, data.length); System.out.println(ps.toString()); System.out.println(ps.toString()); conn.close(); } }