D for Delete
U for update
I for Insert
For delete operations get the userid from the command line and delete the record.
For the update and insert operations get the following information from the command line and insert the record.
Name:
Birth date:
SSC Percentage:
Fees:
Last accessed time:
Decide on the format best suited for input.
I m new to java and also to netbeans.i know ow to connect but i dnt know how to get to many command line arguments..We can give it in project property..but how can i compare that value of command line ::
i m getting no error but not output.
Expand|Select|Wrap|Line Numbers
- package assign22;
- import java.sql.*;
- public class DataOperation {
- public static Connection connection = null;
- public static Statement stmt = null;
- public static ResultSet rs = null;
- public static void main(String[] argv) throws Exception {
- String inputCh = argv[0];
- String id = argv[1];
- String url="jdbc:postgresql:postgres";
- String driver = "org.postgresql.Driver";
- String user = "postgres";
- String pass = "password";
- String query = "select * from tbluser";
- try {
- Class.forName("org.postgresql.Driver");
- System.out.println("hi1");
- connection = DriverManager.getConnection("jdbc:postgresql:postgres", "postgres", "password");
- System.out.println("Connection Successful");
- stmt = connection.createStatement();
- String del = "delete * from tbluser where userid=" + id;
- if (inputCh.equalsIgnoreCase("Delete")) //i also tried to use equals,startsWith methods but failed
- //String del="delete * from tbluser where userid=" + id;
- stmt.executeUpdate(del);
- System.out.println("Deleted one Row Successfully");
- }
- else
- {
- System.out.println("There is some mistake");
- }
- }
- }//end of try */ catch (Exception e) {
- e.getMessage();
- }//end of catch
- }//end of main
- }//end of class
i m giving commandline arguments: Delete 1 //as userid
please help me.