Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8930931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:00:00+00:00 2026-06-15T09:00:00+00:00

I am trying to execute the following query INSERT INTO hotspot(timestamp) VALUES (timestamp with

  • 0

I am trying to execute the following query

INSERT INTO hotspot(timestamp) VALUES 
(timestamp with time zone '2012-10-25 14:00:00 +05:00' at time zone 'EET');

and i want to pass the timestamp as a variable.

My timestamp column is type of timestamp with time zone.

Do you have any idea how this can be done?

When i do… (Java, Postgresql)

    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();

I get a syntax error at or near “$1”

Is there anyway i can overcome this error??
Thank you in advance!!

Update: I tried to use the setTimestamp by the following way…

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();

I suppose that the correct value in the DB should be (regarding that my local time zone is EET (+02))

2012-01-05 11:00:00 +02

but using pgadmin i check the value and i get

2012-01-05 14:00:00 +02

Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:00:03+00:00Added an answer on June 15, 2026 at 9:00 am

    Consider using the setTimestamp() method instead of setString() method. Check this link in order to understand how to use PreparedStatement.

    Edit: As I explained in the comment, check the API reference for setTimestamp() with three parameters:

    Sets the designated parameter to the given java.sql.Timestamp value,
    using the given Calendar object. The driver uses the Calendar object
    to construct an SQL TIMESTAMP value, which the driver then sends to
    the database. With a Calendar object, the driver can calculate the
    timestamp taking into account a custom timezone. If no Calendar object
    is specified, the driver uses the default timezone, which is that of
    the virtual machine running the application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to execute following query: Insert into pligg_links_temp select * from pligg_links
I am trying to execute the following query: INSERT INTO table_listnames (name, address, tele)
I am trying to execute the following query INSERT INTO test (trans_id, voucher_id, trans_date,
I have entered the following query in MySQL: insert into hospital (name,age) values ('william',
I'm trying to execute the following CFML: <cfquery name=koppelData datasource=#request.DataSource#> INSERT INTO t_user_profile (Username,
I am trying to execute the following query in oracle but not able to
I am trying to execute the following query. update share set holder = 22
I am trying to execute the following Query select distinct pincode as Pincode,CAST(Date_val as
I am trying to execute following query through PgAdmin utility. CREATE TABLE svcr.EventLogs (eventId
How to insert data into table in sqlite iPhone? I am trying following, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.