//----------------------------------------------------------------------
//updates Oracle database for the user to store credit card information
//input: credit card type, number, expiration date, pin, ip_address
//output: number of rows updated
//--------------------------------------------------------------------

import java.sql.*;
import java.math.*;
import java.io.*;

class payNow
{
  public static void main (String args [])
       throws SQLException, ClassNotFoundException
  {
	String cardType = args[0];
	String cardNum=args[1];
	String cardExp=args[2];
	String subIPaddr=args[3];
	String subPIN=args[4];

    // Load the Oracle JDBC driver
	DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver ());
Connection conn=DriverManager.getConnection ("jdbc:oracle:thin:lalitha/vaishu@sai:1521:CNS");

    // Create a Statement
    Statement stmt = conn.createStatement ();
   String updtSt = "update billinfo set card_type= '" + cardType + "', card_num = '" + cardNum + "', exp_date=TO_DATE('" + cardExp + "', 'MM-YY') where ip_addr = '" + subIPaddr +"' and mobil_pin = '" + subPIN + "'";

	int insRes = stmt.executeUpdate(updtSt); 
	conn.commit();
	System.out.println(insRes);
	stmt.close();
	} 
}

