hi jamie u have been kind enought to show me the correct path
i sincerely thank u
i wonder if u know java and
servlets cos i have a code which u can see and correct it i having problem in the dates there
i am sending in the code
--------------------------------------------
see my table (title) in seq server database is :
id tdate (datetime-datatype) title
1 22/08/2001 svsdfdfj asdfjefke
2 23/08/2001 ddadkjdkdfj sddeD
.. ............... ...........................
20 10/09/2001 dfdfjskjasdk isdfjdfj
now when i say select * from title;
result
id tdate title
1 2001-08-22 00:00:00.000 xcxcdcj adafvsdsdf
now my requirement
clicking on todays content link i should get todays information(ex. if today is 22/08/2001 i should get the content of 22/08/2001)
how do u do this
using date a = new date(); stores a format whiich is not compatible with tdate
so select * from title where tdate = a; ------error
please correct this and check the code also ....cos u know i am in probabtion period so i will not get a second chance
once confirmed i will not bother u
import java.util.Date;
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class DisplayServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
Date todaysdate = new Date();
out.print("<html><head>");
out.print("</head><body>");
// -----------------------------------------is the syntax correct for
---i mean this i how u write it in servlet program------
out.print("Todays content");
//out.print("<form action=\"");<br /> //out.print( req.getRequestURI() );<br /> //out.print("\" method=\"post\">");
//out.print("<input type=\"submit\" ");<br /> //out.print("value=\" \"> ");
//out.print("Display Records</form>");
out.print("</body></html>");
out.close();
}
public void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {
res.setContentType("text/html");
PrintWriter out = res.getWriter();
String a = req.getParameter("param");
out.print("<html><head>");
out.print("</head><body>");
out.print("<code><pre>");
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc dbc dbc_exmp,userid,pwd");
stmt = con.createStatement();
rs = stmt.executeQuery("SELECT * FROM title where tdate='a'");
while(rs.next()) {
out.print(rs.getObject(1).toString());
out.print("\t");
out.print(rs.getObject(2).toString());
out.print("\t\t");
out.print(rs.getObject(3).toString());
out.print("\n");
}
} catch (SQLException e) {
throw new
ServletException("Servlet Could not display records.", e);
} catch (ClassNotFoundException e) {
throw new
ServletException("JDBC Driver not found.", e);
} finally {
try {
if(rs != null) {
rs.close();
rs = null;
}
if(stmt != null) {
stmt.close();
stmt = null;
}
if(con != null) {
con.close();
con = null;
}
} catch (SQLException e) {}
}
out.print("</pre></code>");
out.print("</body></html>");
out.close();
}
}
this is my code---------------------------
now my problem
i have a table in SQL-SERVER named as title
this table has three fields
1.id
2.tdate----this is of the type datetime
3.content
i am using JRUN 3.0
i want to make a java servlet in which u have a text link
Date todaysdate = new Date();
todays content;
In the servlet :
i am accepting this parameter as
String a = request.getParameter("param");
i will the database connecion---------------------
then
'
select * from title where tdate = 'a';
-----------but this not showing any result
error;
there is something wrong here in he compatitbility of 'a' with tdate