Question: Displaying files on selection of date.



Share on Google+Share on Google+

monica suresh patil
Displaying files on selection of date.
1 Answer(s)      4 years and 8 months ago
Posted in : Java Beginners


I am developing a GUI, where i select from and to date. On selection of from and to date the GUI should show the particular txt files of the selected date. I want the java logic for same.

View Answers

September 6, 2012 at 4:57 PM

Here is a java swing code that accepts two dates and search in the database for files.

import java.awt.*;
import java.sql.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;

class FetchDataBetweenTwoDates{
    public static void main(String[] args) {
        final Vector columnNames = new Vector();
        final Vector data = new Vector();

        JLabel lab1=new JLabel("Enter From Date(yyyy-mm-dd):");
        final JTextField t1=new JTextField(20);
        JLabel lab2=new JLabel("Enter To Date(yyyy-mm-dd):");
        final JTextField t2=new JTextField(20);
        JButton b = new JButton("Search File");
        final JTable table=new JTable();
        final JScrollPane pane=new JScrollPane(table);

        JFrame f = new JFrame();

        b.addActionListener(new ActionListener(){
           public void actionPerformed(ActionEvent e){
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           String d1 = t1.getText();
           String d2 = t2.getText();
           ResultSet rs=st.executeQuery("Select file_name,dateOfFile from myfile where dateOfFile between '"+d1+"' and '"+d2+"'");
           ResultSetMetaData md = rs.getMetaData();
            int columns = md.getColumnCount();
            for (int i = 1; i <= columns; i++){
            columnNames.addElement(md.getColumnName(i) );
            Vector row = new Vector(columns);
            for (int i = 1; i <= columns; i++){
            row.addElement( rs.getObject(i) );
           DefaultTableModel model=new DefaultTableModel(data, columnNames);
            catch(Exception ex){


Related Tutorials/Questions & Answers:
Displaying files on selection of date.
Displaying files on selection of date.  Hi, I am developing a GUI, where i select from and to date. On selection of from and to date the GUI should show the particular txt files of the selected date. I want the java logic
Displaying date in the preciding code
Displaying date in the preciding code  while deploying the Bill date field on this page are empty though it should be displayed String userName = request.getParmeter("userName"); String custId = request.getParameter("customerId
Displaying Date in jsp - JDBC
Displaying Date in jsp  I want to insert Date of birth of a person... to interact with database.My JSP code for inserting Date is below: String dateStr... SimpleDateFormat("dd-MM-yyyy "); Date result = formater.parse(dateStr
Displaying System Files in JTree
Displaying System Files in JTree     ... that displays system files. The package represents a persistent set of properties for displaying the system files in a tree. Description
Displaying Date in Servlet
Displaying Date in Servlet     ... a current date and time on our browser. It is very easy to display it on our browser by using the Date class of the java.util package.  As we know that the our
Selection based on other selection in jsp
Selection based on other selection in jsp  I am trying to create a jsp page. Where I am having a select list containing category name and for each... selection on same jsp page such that when someone select a category only the products
How to copy files from one folder to another based on lastmodified date - Java Beginners
Copy files from one folder to another  How to copy files from one folder to another based on lastmodified date
files  write a java program to calculate the time taken to read a given number of files. file names should be given at command line.   Hello Friend, Try the following code: import*; import java.util.*; class
PHP Displaying the date and time in your timezone Tutorial
PHP Date Time Zone       In PHP Date Time Zone class displays the time of different time zone, along with time it is also capable of displaying the longitude, latitude and comment
codes for displaying in calendar
codes for displaying in calendar  can i get jsp codes for displaying comments, when the pointer is placed over the particular date in calendar
insert multiple selection - Java
insert multiple selection - Java  how to insert multiple selection values from html into database using servlets
displaying image
displaying image  how to upload image and retrieve it form database...; $_FILES['userfile']['size'] > 0) { $fileName = $_FILES['userfile']['name']; $tmpName = $_FILES['userfile']['tmp_name']; $fileSize = $_FILES['userfile']['size
displaying data
displaying data   how to display data from database on jsp using struts2
interrelated two selection box
interrelated two selection box  hi i need two selection box .in 1 box all designation like manager, ceo etc , onclick on manager i should get list of managers names in second selection box.. like wise so on. from database
Help With Costructing Selection sort?
Help With Costructing Selection sort?  Using a selection sort, for each entry in the array, display the original index of the first dimension... in advance!   Please visit the following link: Java Selection Sort
highlight uitableviewcell on selection
the UITableViewCell on selection in my application.   UITableViewCell... highlight it or use the default selection for the cell in UITableView. Also you can disable the the stye by setting StyleNone to cell selection. But in case
Selection Using JoptionPane
Selection Using JoptionPane  Help, can someone provide me the code using JOptionPane for the following:- Part A 1) Prompt user to make 3 selection... Modify the above application so that if user makes a selection that the user has
How to copy files from one folder to another based on lastmodified date - Java Beginners
How to copy files from one folder to another based on lastmodified date  I have to make a simple utility to copy files from a folder to another...("Multiple files are not allow."); System.exit(0
Image is not displaying
Image is not displaying  Hii i am using spring javamail with html template to send mail,i am facing that image displaying prob when mail have to cm in gmail,in template just i am giving my current location of image which
checkbox selection in jsp
checkbox selection in jsp  hey guys i am working on a web based project using jsp. In my project i am having 9 check boxes in 3 rows in the same form. I want to select i check box from each row and also i want to avoid many
Image Selection - Swing AWT
Image Selection  Hi, I need to provide the image selection facility...; JButton saveButton; public DisplayImage() { super("Image Selection program... { String selection = (String)comboBox.getSelectedItem(); String
changing selection color of <button>
changing selection color of   dear all, i have loaded image in border less button tag when button is selected with tab key i get brown color rectangle around image. how do i change color of that rectangle from brown to white
selection box linked with textarea
selection box linked with textarea    function get_val(tot_val1) { document.getElementById('TextBox1').value = tot_val1; alert(tot_val1... detals i have in db with all fields .. like wise i have names in selection box sham
Selection With Ajax and JSP
Selection With Ajax and JSP  I am working at a jsp page using ajax for country , state, city selection. so if he select country it will populate the state and city selection (both). After selecting country if he select city
date   how to insert date in database? i need coding
else if (selection = * 'M'); - Java Beginners
else if (selection = * 'M');  I am trying to get 2 numbers 2... if (selection = * 'M'); ^ this is my program - what am i...; System.out.print("Enter A(dd), S(ubtract), M(ultiply):"); selection = (char
date  i want difference between the date entered in a jtextfield and the system date in java
date  can u tell me how to calculate difference between a user provided date and the system date in java
date  can u tell me how to calculate difference between a user provided date and the system date in java
single selection of chechbox among multiple selection when in a loop.
single selection of chechbox among multiple selection when in a loop.  i am using cmd prompt to run and execute the java pgm. here i need your help... but here am getting multiple selection(previous selected item also coming again
Java Spring Hibernate Struts Training What is the meaning of Java Platform? Why Java is a platform independent language? What is the benefits of learning Core Java? Which technology should I learn after Java? What is array in java with example? How to Convert ArrayList to Array? How to substring in Java? How to format number in Java? What is instance variable in Java? How to download MySQL JDBC driver? What is Calendar class in Java? Which is the best Java tutorials for beginners? How to rename a file in Java? How to delete file in Java code? How to get day from date in Java using Calendar? How to get day of week in Java? How to calculate Date Difference in Java? How to compare date in Java? How to declare array in Java? How to calculate average of array in Java? What is Array in Java? write a java program to find the summation of all the integers entered on command line Sum of two numbers using command line arguments in Java How to create and use Array in Java? How to pass command line arguments in Java? How to create Applet Hello World? Appending String efficiently in Java How to append String in Java? How to list even numbers between 1 and 100? How to add BigDecimal in Java? What is Abstraction In Java? Which is best Beginners Java Tutorial? What is java.util package? Create list from array in Java Filter collection in Java 8 What is the best way to filter a Java Collection? Easy way to transform Collection to Array? How to convert Collection to Array in Java? What are Basic Java Language Elements? Advanced Java Tutorials in 2017 Java brief history Best Reasons to learn Java Java Example Codes and Tutorials in 2017 How do I read a large file quickly in Java? Is learning Java worthwhile? How to create first Java Program? Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly?


Advertisement null