tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ralph Einfeldt <ralph.einfe...@uptime-isc.de>
Subject AW: Indexed Properties and Resultset
Date Tue, 04 Jul 2000 07:49:49 GMT
You don't have to use a RDBMS specific conversion function.
Your jdbc driver does this for you.
Just use:

INSERT INTO TableName (DateColumn) values ( {d '2000-12-31'} )
or
INSERT INTO TableName (DateColumn) values ( {ts '2000-12-31 21:52:56'} )

-----Urspr√ľngliche Nachricht-----
Von: ALEXANDROS KOTSIRAS [mailto:ALEXANDROS_K@prodigy.net]
Gesendet: Montag, 3. Juli 2000 19:32
An: tomcat-user@jakarta.apache.org
Betreff: Re: Indexed Properties and Resultset


Another way to work with dates (easier) is to bind them in the
preparedStatement as String and let the RDBMS to convert it into date.
For example in Oracle you can say :

String myDate = "25/Jul/2000" ;
Insert into table name (DateColumn) values TO_DATE( ? 'DD/Mon/YYYY')
pst.setString(1, myDate) ;

Of course you are using RDBMS specific conversion function which in
Oracle
is TO_DATE


----- Original Message -----
From: Darren Lee Deliang <just_darren@hotmail.com>
To: <tomcat-user@jakarta.apache.org>
Sent: Monday, July 03, 2000 7:49 AM
Subject: RE: Indexed Properties and Resultset


> Hi,
>
> Yes there is class on timestamp and i change wat i need to change but
i
got
> this error when compiling:
>
> D:\FYPJProject\App\WEB-INF\classes\Retraining\ViewCourses.java:116:
cannot
> resolve symbol
> symbol  : method setDate  (int,java.util.Date)
> location: interface java.sql.PreparedStatement
>   st.setDate(1, new java.util.Date());
>                                   ^
> 1 error
> Finished
>
> and below is my code concerning the particular error:
>
> public String displayCourses()
> {
>   String returnedCode;
>   Timestamp start, end, deadline;
>   java.util.Date startdate, enddate, deadlinedate;
>
>   file://Create a prepared statement to call a stored procedure in
server
to
> access courses whose deadline are not past current date.
>
>   String SQLstatement = "SELECT courseNo, courseTitle,
coursestartDate,
> courseendDate, courseDeadline FROM Course WHERE courseDeadline < ?";
>
>   try
>   {
>     PreparedStatement st = con.prepareStatement(SQLstatement);
>     st.setDate(1, new java.util.Date());
>     ResultSet rs = st.executeQuery();
>
>     while(rs.next())
>     {
> SetCourseNo(rs.getString("courseNo"));
> SetCourseTitle(rs.getString("courseTitle"));
> start = rs.getTimestamp("coursestartDate");
> end = rs.getTimestamp("courseendDate");
> deadline = rs.getTimestamp("courseDeadline");
>
> file://Convert to Date objects
> startdate = new java.util.Date(start.getTime() +
> (start.getNanos()/1000000));
> enddate = new java.util.Date(end.getTime() +
(end.getNanos()/1000000));
> deadlinedate = new java.util.Date(deadline.getTime() +
> (deadline.getNanos()/1000000));
>
> SetCoursestartDate(startdate);
> SetCourseendDate(enddate);
> SetCourseDeadline(deadlinedate);
>
> returnedCode = generateCode();
> result.append(returnedCode);
>     }
>     st.close();
>   }
>   catch(SQLException e)
>   {
>     e.printStackTrace();
>   }
>   return result.toString();
> }
>
> I checked the classes and the setDate method takes in an int and
Object.
> What can be the prob? Thanks
>
> Darren
>
> >From: "Rob S." <rslifka@home.com>
> >Reply-To: tomcat-user@jakarta.apache.org
> >To: <tomcat-user@jakarta.apache.org>
> >Subject: RE: Indexed Properties and Resultset
> >Date: Fri, 30 Jun 2000 19:05:33 -0700
> >
> >Hi Darren,
> >
> > > one more thing, i checked against the tables and i realise the
jdbc
type
> > > conversion supported by jdbc for ms sal server 7.0 is TIMESTAMP
> > > to DATETIME
> > > and not Date to DAte, so how should i change the below code?
> >
> >Hint:  in the java.sql package, there's a class having something to
do
with
> >TIMESTAMP. ;)
> >
> >Good luck!
> >
> >- r
> >
> >
>
>-----------------------------------------------------------------------
---
> >To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> >For additional commmands, email: tomcat-user-help@jakarta.apache.org
> >
>
>
________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at
http://www.hotmail.com
>
>
>
------------------------------------------------------------------------
--
> To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commmands, email: tomcat-user-help@jakarta.apache.org
>


------------------------------------------------------------------------
--
To unsubscribe, email: tomcat-user-unsubscribe@jakarta.apache.org
For additional commmands, email: tomcat-user-help@jakarta.apache.org


Mime
View raw message