tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Darren Lee Deliang" <just_dar...@hotmail.com>
Subject RE: Indexed Properties and Resultset
Date Mon, 03 Jul 2000 11:49:28 GMT
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;

  //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");

	//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


Mime
View raw message