File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retreiving data

 
Beena Thomas
Greenhorn
Posts: 5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
import java.sql.*;
import java.text.*;
import java.util.*;
String instr,startMonth,startDate,startYear,endMonth,endDate,endYear,sDate,eDate;

instr=request.getParameter("instruments");
startMonth=request.getParameter("startMonth");
startDate=request.getParameter("startDate");
startYear=request.getParameter("startYear");
endMonth=request.getParameter("startMonth");
endDate=request.getParameter("startDate");
endYear=request.getParameter("startYear");
sDate=startMonth+"/"+startDate+"/"+startYear;
eDate=endMonth+"/"+endDate+"/"+endYear;


Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc dbc:myDatabase");
Statement stmt=con.createStatement();
String query ="SELECT Grantor,Grantee,Location FROM Retrieval WHERE File_Date Between sDate And eDate ";

ResultSet rs=stmt.executeQuery(query);

while(rs.next())
{
String grantor=rs.getString("Grantor");
String grantee=rs.getString("Grantee");
String location=rs.getString("Location");
}
con.close();
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
nice code.
Jamie
[This message has been edited by Jamie Robertson (edited November 28, 2001).]
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what is the data type of File_Date in the database? if it is a date field and you are using an access database, then try

The way you had your query set up, it was not substituting values for sDate and eDate.
Jamie
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you could also use a PreparedStatement;

If anyone knows a more natural way to convert the dates post it...I'm not too familiar with manipulating dates
I like using PreparedStatements where possible. Seems to be less problems further down the road.
Jamie
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic