Thanks for all for your help.
:)
Thankyou very much.

Rgd:
ParveenThakur
9988208440


On Mon, Jan 17, 2011 at 10:10 PM, MURALI <murali.munna...@gmail.com> wrote:

>
> You dint implement the loop well.
>
> One more thing  " studentid " should be primary key at databasae level,this
> prevents duplicate insertion.
> On Tue, Jan 18, 2011 at 4:21 AM, jose luis garcia 
> <pepewich...@gmail.com>wrote:
>
>>  you have :
>>
>>
>>   do{
>>          .
>>          .
>>          .
>>      //all cases
>>
>>
>> }while(choice!=0);
>>
>>
>> the sentence "do-while" don“t out go, if you choice 1, 2, 3 ... because
>> the cycle "do-while" be repeated while "while(condition==true)".
>>
>> Therefore the insert is repeat several times.
>>
>>
>>
>> 2011/1/17 Parveen Thakur <parveenkumar...@gmail.com>
>>
>>  HI Friends,
>>>
>>>
>>>         Please Help me!! when i Rum this program and insert values in
>>> table then multiple rows are created automatically in the data base . I have
>>> no idea about this ??
>>>
>>>
>>> code is written below:
>>>
>>>
>>> import java.sql.*;
>>> import java.lang.*;
>>> import java.util.*;
>>>
>>>
>>>
>>> class Student
>>> {
>>> int    choice;
>>> int    id;
>>>     float  sfees;
>>>     float  fees;
>>> float  rfees;
>>> float  balance;
>>> String name;
>>> String sclass;
>>> String phno;
>>> String address;
>>> String clgename;
>>> String course;
>>> String stream;
>>> String driver="com.mysql.jdbc.Driver";
>>> String path="jdbc:mysql://localhost/vee";
>>> String root="root";
>>> String pass="root";
>>>  void mainMenu()
>>> {
>>> Scanner s = new Scanner(System.in);
>>>
>>>    System.out.println("\t********************************");
>>> System.out.println("\t\tPlease Select Any One");
>>> System.out.println("\t********************************");
>>> System.out.println("1.InsertRecord");
>>> System.out.println("2.ShowRecord");
>>> System.out.println("3.UpdateRecord");
>>> System.out.println("4.DeleteRecord");
>>> System.out.println("5.SearchRecord");
>>> System.out.println("0.Exit");
>>>     System.out.println("\n\nEnter Choice          :");
>>>    choice=s.nextInt();
>>>
>>>        System.out.println("\t********************************");
>>>    System.out.println("\t\tSTUDENT DETAIL");
>>>    System.out.println("\t********************************");
>>>    System.out.print("Enter id             :");
>>>    id=s.nextInt();
>>>    System.out.print("Enter name           :");
>>>    name=s.next();
>>>    System.out.print("Enter sclass         :");
>>>    sclass=s.next();
>>>    System.out.print("Enter phno           :");
>>>    phno=s.next();
>>>    System.out.print("Enter address        :");
>>>    address=s.next();
>>>    System.out.print("Enter clgename       :");
>>>    clgename=s.next();
>>>    System.out.print("Enter course         :");
>>>    course=s.next();
>>>    System.out.print("Enter stream         :");
>>>    stream=s.next();
>>>    System.out.print("Enter fees           :");
>>>    fees=s.nextFloat();
>>>    System.out.print("Enter rfees          :");
>>>    rfees=s.nextFloat();
>>>    float totalfees=fees+rfees;
>>>    System.out.println("Your Totalfees is    :"+totalfees);
>>>    System.out.println("\n\nsubmit sfees         :");
>>>    sfees=s.nextFloat();
>>>  if(sfees==totalfees)
>>> {
>>>  System.out.println("Your fees is submitted");
>>> }
>>> else
>>> {
>>> System.out.println("");
>>> }
>>>  if(sfees==rfees)
>>> {
>>> balance=totalfees-sfees;
>>> System.out.println("your Balance is  :"+balance);
>>> System.out.println("Your Rfees is submit ");
>>> }
>>> else
>>> {
>>> System.out.println("");
>>> }
>>>     if(sfees<totalfees && sfees!=rfees)
>>> {
>>> balance=totalfees-sfees;
>>> System.out.println("your Balance is  :"+balance);
>>>  }
>>> else
>>> {
>>> System.out.println("");
>>> }
>>>
>>>  do
>>> {
>>> switch(choice)
>>> {
>>> case 1:
>>>  try
>>> {
>>>
>>> Class.forName(driver);
>>> Connection con=DriverManager.getConnection(path,root,pass);
>>> PreparedStatement p = con.prepareStatement("insert into studentInfo
>>> values(?,?,?,?,?,?,?,?,?,?)");
>>> p.setInt(1,id);
>>> p.setString(2,name);
>>> p.setString(3,sclass);
>>> p.setString(4,phno);
>>> p.setString(5,address);
>>> p.setString(6,clgename);
>>> p.setString(7,course);
>>> p.setString(8,stream);
>>> p.setFloat (9,fees);
>>> p.setFloat (10,rfees);
>>> p.executeUpdate();
>>> p.close();
>>> con.close();
>>> }
>>> catch(Exception e)
>>> {
>>> System.out.println(e.getMessage());
>>> }
>>>  break;
>>>  case 2:
>>>  String select="select * from studentInfo";
>>> try
>>> {
>>> Class.forName(driver);
>>> Connection con = DriverManager.getConnection(path,root,pass);
>>> Statement st = con.createStatement();
>>> ResultSet rs = st.executeQuery(select);
>>>  while(rs.next())
>>> {
>>> System.out.println(rs.getString(1)+" "+rs.getString(2)+"
>>> "+rs.getString(3)+" "+rs.getString(4));
>>> }
>>> rs.close();
>>> con.close();
>>> }
>>>  catch(Exception e)
>>> {
>>> System.out.println(e.getMessage());
>>> }
>>>  break;
>>> case 3:
>>>  try
>>> {
>>> Class.forName(driver);
>>> Connection con=DriverManager.getConnection(path,root,pass);
>>> PreparedStatement ps =con.prepareStatement("update studentInfo set id=?
>>> where id=?,");
>>> ps.setInt(1,id);
>>> System.out.println(ps.executeUpdate());
>>> ps.close();
>>> con.close();
>>>  }
>>>  catch(Exception e)
>>> {
>>> System.out.println(e.getMessage());
>>> }
>>>  break;
>>>  case 4:
>>>  try
>>> {
>>> Class.forName(driver);
>>> Connection con=DriverManager.getConnection(path,root,pass);
>>> PreparedStatement ps = con.prepareStatement("Delete from studentInfo
>>> where id=?");
>>> ps.setInt(1,id);
>>> ps.executeUpdate();
>>> ps.close();
>>> con.close();
>>> }
>>>  catch(Exception e)
>>> {
>>> System.out.println(e.getMessage());
>>> }
>>>  break;
>>> case 5:
>>>  try
>>> {
>>> Class.forName(driver);
>>> Connection con = DriverManager.getConnection(path,root,pass);
>>> PreparedStatement ps =con.prepareStatement("select id from studentInfo
>>> where id=?");
>>> ps.setInt(1,id);
>>> ResultSet rs = ps.executeQuery();
>>>  while(rs.next())
>>> {
>>> System.out.println(rs.getString(1));
>>> }
>>> rs.close();
>>> con.close();
>>> }
>>>  catch(Exception e)
>>> {
>>> System.out.println(e.getMessage());
>>> }
>>>
>>> break;
>>> default:
>>> System.out.println("exit(0)");
>>> }
>>>   }while(choice!=0);
>>> }
>>> }
>>> public class StudentDemo
>>> {
>>> public static void main(String[] args)
>>> {
>>> Student s = new Student();
>>> s.mainMenu();
>>> }
>>> }
>>>
>>> --
>>> Best Regards And Thanks :
>>> Parveen Thakur,
>>> Contact no.-9988208440.
>>>
>>> --
>>> To post to this group, send email to
>>> javaprogrammingwithpassion@googlegroups.com
>>> To unsubscribe from this group, send email to
>>> javaprogrammingwithpassion+unsubscr...@googlegroups.com<javaprogrammingwithpassion%2bunsubscr...@googlegroups.com>
>>> For more options, visit this group at
>>> http://groups.google.com/group/javaprogrammingwithpassion?hl=en
>>
>>
>>   --
>> To post to this group, send email to
>> javaprogrammingwithpassion@googlegroups.com
>> To unsubscribe from this group, send email to
>> javaprogrammingwithpassion+unsubscr...@googlegroups.com<javaprogrammingwithpassion%2bunsubscr...@googlegroups.com>
>> For more options, visit this group at
>> http://groups.google.com/group/javaprogrammingwithpassion?hl=en
>>
>
>  --
> To post to this group, send email to
> javaprogrammingwithpassion@googlegroups.com
> To unsubscribe from this group, send email to
> javaprogrammingwithpassion+unsubscr...@googlegroups.com<javaprogrammingwithpassion%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/javaprogrammingwithpassion?hl=en
>



-- 
Best Regards And Thanks :
Parveen Thakur,
Contact no.-9988208440.

-- 
To post to this group, send email to javaprogrammingwithpassion@googlegroups.com
To unsubscribe from this group, send email to 
javaprogrammingwithpassion+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to