Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Shopping cart application

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Shopping cart application

    This is my payment web service code...but iam not able to identify the mistake.could you just help me with sample payment service code for shopping cart
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
     
    package payment;
     
     
    import java.sql.*;
    import javax.annotation.Resource;
    import javax.jws.WebMethod;
    import javax.jws.WebParam;
    import javax.jws.WebService;
    import javax.sql.DataSource;
     
    /**
     *
     * @author Vijayalekshmy
     */
    @WebService()
    public class payment {
        @Resource(name = "data2")
        private DataSource data2;String userName=new String("");
        String passWord=new String("");
    String name=new String("");
    String str, p, q, r;
     
     
     
        /**
         * Web service operation
         */
     
        @WebMethod(operationName = "pay")
        public String pay(@WebParam(name = "CCNO")
        String CCNO, @WebParam(name = "CVV")
        String CVV, @WebParam(name = "Amount")
        float Amount) {
            //TODO write your implementation code here:
    try {
                str="";
                p="";
    q="";
    r=".";
         Class.forName("com.mysql.jdbc.Driver");
                Connection con = DriverManager.getConnection("jdbc:mysql://localhost/test","root","ashwin");
     
                ResultSet rs=null, rs1;
                String sq = "select cno, cvv from payment";
      Statement s = con.createStatement();
      Statement s1 = con.createStatement();
      Statement st =  con.createStatement();
      s.executeQuery (sq);
       rs = s.getResultSet();
       while (rs.next()){
          /* str="Incorrect";
        userName=rs.getString("cno");
        passWord=rs.getString("cvv");
        if(userName.equals(userNam)&&passWord.equals(passwrd)){
            rs1=st.executeQuery("update payment set ctype='"+passwrd+"' where cno='"+userNam+"'");
     str="Thanks for Shopping!";
          }*/
           str+=rs.getString(1)+","+rs.getString(2)+",";
           p=rs.getString(1);
     
           q=rs.getString(2);
          if(CCNO.equals(rs.getString("ccno"))&&CVV.equals(rs.getString("cvv"))){
            System.out.print(""+p+CCNO);
            //rs1=st.executeQuery("update payment set ctype='"+passwrd+"' where cno='"+userNam+"'");
     
                  String sq1 =" update payment set bal=bal-"+Amount+" where ccno='"+CCNO+"'";
                   s1.executeUpdate(sq1);
                    r="thanks ";
           }
           }
        rs.close ();
          s.close ();
          }catch(Exception e){
          System.out.println("Exception is ;"+e);
          }
     
        return r;
        }
     
    }
    Last edited by helloworld922; November 28th, 2012 at 01:10 PM. Reason: please use [code] tags


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Shopping cart application

    We can't identify the mistake either. What does this code do? What do you expect it to do? Does it throw an error? Exhibit some strange behavior? Something else? Which part of this code is broken? Where is your SSCCE?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Super Moderator curmudgeon's Avatar
    Join Date
    Aug 2012
    Posts
    1,130
    My Mood
    Cynical
    Thanks
    64
    Thanked 140 Times in 135 Posts

    Default Re: Shopping cart application

    Quote Originally Posted by ashkrish View Post
    ....could you just help me with sample payment service code for shopping cart
    Again, this isn't a request the code service. Tell us about your errors and let's fix it. First off, is this even your code?

Similar Threads

  1. Shopping cart application
    By ashkrish in forum What's Wrong With My Code?
    Replies: 1
    Last Post: November 28th, 2012, 12:08 PM
  2. Replies: 1
    Last Post: February 8th, 2012, 05:16 PM
  3. Simple Shopping Cart..... not so simple
    By jpsider in forum What's Wrong With My Code?
    Replies: 5
    Last Post: January 20th, 2012, 02:18 PM
  4. Need help with simple Shopping cart math
    By I hate Java! in forum Loops & Control Statements
    Replies: 3
    Last Post: November 6th, 2011, 10:46 PM
  5. Validating fields in a js shopping cart
    By rockc in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 10th, 2010, 03:37 PM