java project using CMD Source Code Download
import java.sql.*;
import java.*;
import java.io.*;
class whileInfinite
{
public static void main(String s[])
{
try{
while(true)
{
System.out.println("Select Your Choice :");
System.out.println("________________________________________");
System.out.println("1. Insert record :");
System.out.println("2. disply all records :");
System.out.println("3. display Specific record :");
System.out.println("4. update record:");
System.out.println("5. delete Record:");
System.out.println("6. Exit:");
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter your choice");
int choice = Integer.parseInt(reader.readLine());
System.out.println("yo entered"+ choice);
switch(choice)
{
case 1:whileInfinite obj=new whileInfinite();
obj.Insert();
break;
case 2:System.out.println("Select one");
break;
case 3:System.out.println("Select one");
break;
case 4:System.out.println("this is four");
break;
case 5:System.out.println("Select one");
break;
case 6:System.exit(0);
default:System.out.println("wrong choice");
break;
}
}
}
catch( Exception e)
{
System.out.println(""+e);
}
}
void Insert()
{
try
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
// it is used to accept value runtime
System.out.println("Enter The name");
String nm = reader.readLine();
System.out.println("Enter The ID");
int id = Integer.parseInt(reader.readLine());
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//driver load
Connection con=DriverManager.getConnection("jdbc:odbc:demodb");
// connection
PreparedStatement psmt=con.prepareStatement("insert into demo(id,dname)values(?,?)");
psmt.setInt(1,id);
psmt.setString(2,nm);
int result=psmt.executeUpdate();
System.out.println("record Inserted"+result);
con.close();
}
catch( Exception e)
{
System.out.println(""+e);
}
}
}