Hi!,
i have 48 errors with following code.Plzzzzzzz.......can anyone tell me the mistake that i had done.


thanks in advance.

this is my code

import java.lang.String;
import java.lang.Integer;
import java.lang.Float;
import java.util.Hashtable;
import java.util.Enumeration;
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class testM{
public static void main(String[] args){ 

 public int ccnumbert=0;
  public String card_typet;
  public int montht=0;
  public int yeart=0;
  public String fullnamet;
  public int ccvt=0;
  public int costt=0;
  checkCCDetails("4343","visa","6","2000","bj","666",5000);
  }
public int checkCCDetails(String ccnumber,String card_type,String month,String year,String fullname,String ccv,int totCst){
  Connection con=null;
  ResultSet rs=null;
  Statement stmt=null;
  
  int flag=0;
  ccnumbert=Integer.parseInt(ccnumber);
  card_typet=card_type;
  montht=Integer.parseInt(month);
  yeart=Integer.parseInt(year);
  fullnamet=fullname;
  ccvt=Integer.parseInt(ccv);
 costt=totCst;
  
  public int ccnumberc=0;
  public String card_typec=null;
  public int monthc=0;
  public int yearc=0;
  public String fullnamec=null;
  public int ccvc=0;
  public int bal=0;
  
  try{
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  con=DriverManager.getConnection("jdbc:odbc:MY-PIZZA","","");
  String q="select * from Accounts where ccnumber="+ccnumbert+" ";

  stmt=con.createStatement();
  rs=stmt.executeQuery(q);
  if(rs !=null){  
 while( rs.next()){
  
  ccnumberc=rs.getInt(1);
  card_typec=rs.getString(2);
  monthc=rs.getInt(3);
  yearc=rs.getInt(4);
  fullnamec=rs.getString(5);
  ccvc=rs.getInt(6);
  bal=rs.getInt(7);
  }
  }
 }catch(SQLException e){
 }
 catch(ClassNotFoundException ee){
 }
 finally{
 
   if(rs !=null){
    rs.close();
    rs=null;
   }
   if(stmt !=null){
    stmt.close();
    stmt=null;
   }
  if(con !=null){
    con.close();
    con=null;
   }
  }//end finally*/
  
  
  
  boolean i=check(ccnumberc,card_typec,monthc,yearc,fullnamec,ccvc);
  if(i==true && bal>=costt)
	flag=1;//payment succeeded	
  else if (i==true && bal<costt)
  flag=2;//dettails are ok but insufficient balance  
  else
  flag=3;//details are wrong 
  
  
  return flag;
  }
  
  
public boolean check(int ccnumberc,String card_typec,int monthc,int yearc,String fullnamec,int ccvc){
 
  if(ccnumbert==ccnumberc && card_typet==card_typec && montht==monthc && yeart==yearc && fullnamet==fullnamec && ccvt==ccvc)
		return true;
		else return false;
  

  }
  }

Well, concentrate on the first one and try to fix that, then compile again, and again, concentrate the "new" first error, repeat the process.

May I point out the following errors after glancing at your code.
1. javax.servlet is included in J2EE platform rather than J2SE. There for the package does not exist on our J2SE platform.
2. any local variables in a method should not have accessing modifier. Only the data members, that is, the attributes are indicated by accessing modifiers, such as public, friendly, protected, and private.
3. the method checkCCDetails() should be static so that the main method may call it.

May I point out the following errors after glancing at your code.
1. javax.servlet is included in J2EE platform rather than J2SE. There for the package does not exist on our J2SE platform.
2. any local variables in a method should not have accessing modifier. Only the data members, that is, the attributes are indicated by accessing modifiers, such as public, friendly, protected, and private.
3. the method checkCCDetails() should be static so that the main method may call it.

Thanks for replying.
i cheked things you said.
but still i get errors.
actually this is the class.

package Details;

import java.lang.String;
import java.lang.Integer;
import java.lang.Float;
import java.util.Hashtable;
import java.util.Enumeration;
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;


public class CusDetails {

Hashtable cusdata=new Hashtable();
public void derCusData(String fname,String sname,String phone,String email,String address1,String street,String address3,String area){
String[] data={fname,sname,phone,email,address1,street,address3,area};
cusdata.put(fname,data);

}//end of derCusData

 public Enumeration getEnumeration() {
    return cusdata.elements();
  }
   
  public int checkCCDetails(String ccnumber,String card_type,String month,String year,String fullname,String ccv,int totCst){
  Connection con=null;
  ResultSet rs=null;
  Statement stmt=null;
  
  public int flag=0;
  public int ccnumbert=Integer.parseInt(ccnumber);
  public String card_typet=card_type;
  public int montht=Integer.parseInt(month);
  public int yeart=Integer.parseInt(year);
  public String fullnamet=fullname;
  public int ccvt=Integer.parseInt(ccv);
  public int costt=totCst;
  
  public int ccnumberc=0;
  public String card_typec=null;
  public int monthc=0;
  public int yearc=0;
  public String fullnamec=null;
  public int ccvc=0;
  public int bal=0;
  
  try{
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  con=DriverManager.getConnection("jdbc:odbc:MY-PIZZA","","");
  String q="select * from Accounts where ccnumber="+ccnumbert+" ";

  stmt=con.createStatement();
  rs=stmt.executeQuery(q);
  if(rs !=null){  
 while( rs.next()){
  
  ccnumberc=rs.getInt(1);
  card_typec=rs.getString(2);
  monthc=rs.getInt(3);
  yearc=rs.getInt(4);
  fullnamec=rs.getString(5);
  ccvc=rs.getInt(6);
  bal=rs.getInt(7);
  }
  }
 }catch(SQLException e){
 }catch(ClassNotFoundException ee){
 }finally{
 
   if(rs !=null){
    rs.close();
    rs=null;
   }
   if(stmt !=null){
    stmt.close();
    stmt=null;
   }
   if(con !=null){
    con.close();
    con=null;
   }
  }//end finally
  
  boolean i=check(ccnumberc,card_typec,monthc,yearc,fullnamec,ccvc);
  if(i==true && bal>=costt){
	flag=1;//payment succeeded
	}
  if (i==true && bal<costt){
  flag=2;//dettails are ok but insufficient balance
  }
  if(i==false){
  flag=3;//details are wrong 
  }
  
  return (flag);
  }
  
  
  
  public boolean check(int ccnumberc,String card_typec,int monthc,int yearc,String fullnamec,int ccvc){
  boolean ok=false;
  if(ccnumberc==ccnumbert && card_typec==card_typet && monthc==montht && yearc==yeart && fullnamec==fullnamet && ccvc==ccvt){
		ok=true;
		return (ok);
		}
	return (ok);
  }

  }
  
  i get 23 errors.i really dont understand why.Please help me!!

but still i get errors.

Please post your errors.

Please post your errors.

C:\tomcat\apache-tomcat-6.0.16\webapps\pizzatest1234\prog>javac new4.java
new4.java:32: illegal start of expression
  public int flag=0;
  ^
new4.java:49: illegal start of type
  try{
  ^
new4.java:68: illegal start of type
 }catch(SQLException e){
  ^
new4.java:68: ';' expected
 }catch(SQLException e){
                      ^
new4.java:69: illegal start of type
 }catch(ClassNotFoundException ee){
  ^
new4.java:69: ';' expected
 }catch(ClassNotFoundException ee){
                                 ^
new4.java:70: illegal start of type
 }finally{
  ^
new4.java:87: illegal start of type
  if(i==true && bal>=costt){
  ^
new4.java:87: <identifier> expected
  if(i==true && bal>=costt){
      ^
new4.java:87: <identifier> expected
  if(i==true && bal>=costt){
                   ^
new4.java:87: <identifier> expected
  if(i==true && bal>=costt){
                          ^
new4.java:90: illegal start of type
  if (i==true && bal<costt){
  ^
new4.java:90: <identifier> expected
  if (i==true && bal<costt){
       ^
new4.java:90: > expected
  if (i==true && bal<costt){
                          ^
new4.java:93: illegal start of type
  if(i==false){
  ^
new4.java:93: <identifier> expected
  if(i==false){
      ^
new4.java:97: illegal start of type
  return (flag);
  ^
new4.java:97: <identifier> expected
  return (flag);
              ^
new4.java:102: class, interface, or enum expected
  public boolean check(int ccnumberc,String card_typec,int monthc,int yearc,String fullnamec,int ccvc){
         ^
new4.java:104: class, interface, or enum expected
  if(ccnumberc==ccnumbert && card_typec==card_typet && monthc==montht && yearc==yeart && fullnamec==fullnamet && ccvc==ccvt){
  ^
new4.java:106: class, interface, or enum expected
                return (ok);
                ^
new4.java:107: class, interface, or enum expected
                }
                ^
new4.java:109: class, interface, or enum expected
  }
  ^
23 errors

At line 27 your start the defnition of a method:
public int checkCCDetails(

Then within that method you try to use the public modifier.
You can NOT use public with variables local to a method.
Remove all the "public" modifiers from all the variables inside of any methods.

The compiler was confused at that point and some of the following "errors" might be ok.

Make those changes and compile it again.

At line 27 your start the defnition of a method:
public int checkCCDetails(

Then within that method you try to use the public modifier.
You can NOT use public with variables local to a method.
Remove all the "public" modifiers from all the variables inside of any methods.

The compiler was confused at that point and some of the following "errors" might be ok.

Make those changes and compile it again.

THANK YOU VERY MUCH.I was wondering what to do.It worked.Once agin THANK YOU VERY VERY MUCH!!!!!.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.