?
Solved

timestamp with java

Posted on 2003-03-31
2
Medium Priority
?
14,642 Views
Last Modified: 2013-12-09
Hi all,

I am using Interbase 6 and 7.I can reproduce the problem in both versions of IB
I have columns of data type TIMESTAMP.

I have a java program for inserting records, it seems that the data that gets entered into these TIMESTAMP columns are only capturing the date.

here is the code below to convert java.util.Date to java.sql.Date to be used with a prepared statement.
i need it to capture the date and time.

    private java.sql.Date convert(java.util.Date d)
    {
        java.sql.Date res = new java.sql.Date(new java.util.Date().getTime());

        if (d != null)
        {
            res = new java.sql.Date(d.getTime());
        }
        return res;
    }

d that gets passed in is new java.util.Date(), i can see the long values when i am in the debugger
is there a setting that i need to set on the Interbase database?

setting the prepared statment as follows
ps.setDate(some pos, convert(new java.util.Date()));

pls help

thx
0
Comment
Question by:ahuen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 200 total points
ID: 8239758
Try this:

ps.setTimestamp(somePos, new Timestamp(new java.util.Date().getTime());
0
 

Author Comment

by:ahuen
ID: 8239778
thx

found the same solution

thx
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A company’s centralized system that manages user data, security, and distributed resources is often a focus of criminal attention. Active Directory (AD) is no exception. In truth, it’s even more likely to be targeted due to the number of companies …
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question