Current location: Hot Scripts Forums » Programming Languages » Everything Java » help me plz...


help me plz...

Reply
  #1 (permalink)  
Old 03-30-06, 01:25 AM
josethomasrajesh josethomasrajesh is offline
Newbie Coder
 
Join Date: Mar 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Question help me plz...


hi to all

help me plz
i am doing program in java

description of my program

1. i created start date and end date, it has to compare, then the dates has to go to the database,

2. in databse i created a table called holidays(in holiday table there is a list of public holidays and weekend )

3. the start date and end date has to go there and check these dates are in public holidays are in weekends

if yes means it has tel reaining days are weekdays


here is my error program

in my program there is a error , i tried to solve it, if any one knows plz help me

Code:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Date;
import java.text.*;
import java.sql.*;


public class compareDates
{     		
	public static boolean compareDates(String dDateA, String dDateB)
        	{
			  Connection con = null;
              Statement stmt = null;
              ResultSet rs = null;
	try
	{              
              String driverName = "com.mysql.jdbc.Driver"; 
              Class.forName(driverName);
			
	String serverName = "192.168.10.5";
	String mydatabase = "Trainees";
	String url = "jdbc:mysql://" + serverName +  "/" + mydatabase; // a JDBC url
	String username = "josep";
	String password = "josep";
	con = DriverManager.getConnection(url, username, password);
	stmt=con.createStatement();
			
             System.out.println("Entered into Compare Dates");
             SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy");     
             ParsePosition pos = new ParsePosition(0);
             ParsePosition pos1 = new ParsePosition(0);
   
             Date startDate = formatter.parse(dDateA, pos);
             Date endDate = formatter.parse(dDateB, pos1);
        	 
             boolean flag = false;
             System.out.println("Start Date :"+startDate);
             System.out.println("End Date   :"+endDate);
             if(startDate.before(endDate))
             flag = true;
             System.out.println("Compare Flag :"+flag);
        
             PreparedStatement pStatement = con.prepareStatement("insert into Holiday values(?,?)");
            
              
             pStatement.setDate(1, formatter.parse(dDateA)); 
             pStatement.setDate(2, formatter.parse(dDateB));
              
             pStatement.executeUpdate();
             pStatement.close();
  
             
	
               }
         catch(Exception e)
         {
         System.err.println("Exception: " + e.getMessage());
         } 
    	finally 
    	{
        	try 
        	{
        	if(con != null)
        	con.close();
        	} 
      	catch(SQLException e) 
     	{ }
  	}
	return false;

   }      

    public static void main(String args[])throws IOException
  {
		
		
  	try
  	{
   	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

   	System.out.println ("Enter Start Date (dd/mm/yyyy)");
   	String dDateA=br.readLine();
   	System.out.println("Enter End Date (dd/mm/yyyy)");
   	String dDateB= br.readLine();

   	compareDates cd= new compareDates();
   	boolean before = cd.compareDates(dDateA,dDateB);;
   	if(!before)
    	System.out.println("Please enter the Correct Date ");
  	}
  	catch(Exception e)
  	{
              System.out.println("Exception in main Class :"+e.getMessage());
  	} 
  	
  	
  }
 
}

here is my error

>javac compareDates.java
compareDates.java:47: cannot find symbol
symbol : method setDate(int,java.util.Date)
location: interface java.sql.PreparedStatement
pStatement.setDate(1, formatter.parse(dDateA));
^
compareDates.java:48: cannot find symbol
symbol : method setDate(int,java.util.Date)
location: interface java.sql.PreparedStatement
pStatement.setDate(2, formatter.parse(dDateB));
^
2 errors

in my program there is a error , i tried to solve it, if any one knows plz help me

help me plzzzzz
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
hi 2 everyone , PLZ HELP ME OUT !!!! ask_naz ASP 0 12-04-05 10:58 AM
i need php game script plz .... HOSSAM007 Script Requests 2 10-04-05 05:52 PM
want to validate Time in asp formconfused: plz help sumitbharatiya JavaScript 1 05-06-05 02:44 PM
Searching after a "Skillscript", or help for this one: -important plz read!!!- Dr. Prozessor Script Requests 0 01-25-05 07:57 AM
Plz help me about WEB MENU phpnawin HTML/XHTML/XML 3 12-06-04 01:12 PM


All times are GMT -5. The time now is 05:36 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.