title: How to pass string with ' ' (timestamp) in prepared statement?
body: <p>I am trying to execute the following query</p>
  
  <pre><code>INSERT INTO hotspot(timestamp) VALUES 
  (timestamp with time zone '2012-10-25 14:00:00 +05:00' at time zone 'EET');
  </code></pre>
  
  <p>and i want to pass the timestamp as a variable.</p>
  
  <p>My timestamp column is type of timestamp with time zone.</p>
  
  <p>Do you have any idea how this can be done?</p>
  
  <p>When i do... (Java, Postgresql)</p>
  
  <pre><code>    String stm= "INSERT INTO hotspot(timestamp) VALUES(timestamp with time zone ? at time zone 'EET')";
      pst = con.prepareStatement(stm);
      pst.setString(1, "2012-08-24 14:00:00 +05:00");
      pst.executeUpdate();
  </code></pre>
  
  <p>I get a  syntax error at or near "$1" </p>
  
  <p>Is there anyway i can overcome this error??
  Thank you in advance!!</p>
  
  <p><em><strong>Update:</em></strong> I tried to use the setTimestamp by the following way...</p>
  
  <pre><code>Calendar c=Calendar.getInstance(TimeZone.getTimeZone("GMT+05:00"));
  String stm= "INSERT INTO hotspot(timestamp) VALUES(?)";
  pst = con.prepareStatement(stm);
  pst.setTimestamp(1,Timestamp.valueOf("2012-01-05 14:00:00"), c );
  pst.executeUpdate();
  </code></pre>
  
  <p>I suppose that the correct value in the DB should be (regarding that my local time zone is EET (+02))</p>
  
  <p>2012-01-05 11:00:00 +02   </p>
  
  <p>but using pgadmin i check the value and i get</p>
  
  <p>2012-01-05 14:00:00 +02</p>
  
  <p>Any suggestions?</p>