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 4 of 4

Thread: simple login web service

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default simple login web service

    Hi,
    I am kind of newb in java web service development , i want to write a simple web service application that client send username and password for server , then after authenticate that with mysql data base , the session for current user should be created, can anybody help me for doing that?!
    p.s:I am using netbeans.
    Thanks.


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: simple login web service


  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: simple login web service

    Thanks for your help, but this toturial is really huge and confusing, do you know any simple one?! for example something like this.
    Thanks a lot.

  4. #4
    Junior Member
    Join Date
    Jan 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: simple login web service

    please someone tell me why this code is failed on testing:
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import javax.annotation.Resource;
    import javax.jws.WebMethod;
    import javax.jws.WebParam;
    import javax.jws.WebService;
    import javax.sql.DataSource;
     
    @WebService()
    public class Login {
        @Resource(name = "dataproject")
        private DataSource dataproject;
     
        /**
         * Web service operation
         */
        @WebMethod(operationName = "Select")
        public String Select(@WebParam(name = "uname")
        String uname, @WebParam(name = "passwd")
        String passwd) {
     
            try {
                Class.forName("com.mysql.jdbc.Driver");
                Connection con =
    DriverManager.getConnection("jdbc:mysql://localhost:3306/project",
    "root", "1234");
                PreparedStatement st =
    con.prepareStatement("select * from user where username='"+uname+"' and password='"+passwd+"'");
                ResultSet rs=st.executeQuery();
                int rowCount=rs.getRow();
                if(rowCount==0) return "Username and or password is not correct!";
                else return "connected!";
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
            //TODO write your implementation code here:
            return "Username and or password is not correct!";
        }
     
    }

Similar Threads

  1. Unable to open web service tester page
    By oneofthelions in forum JavaServer Pages: JSP & JSTL
    Replies: 0
    Last Post: December 13th, 2009, 06:20 PM
  2. not so simple, simple swing question box
    By wolfgar in forum AWT / Java Swing
    Replies: 2
    Last Post: November 20th, 2009, 03:47 AM
  3. Replies: 2
    Last Post: November 19th, 2009, 11:55 PM
  4. Replies: 1
    Last Post: July 28th, 2009, 02:15 AM
  5. Free java hosting service providers
    By servlet in forum Java Servlet
    Replies: 1
    Last Post: May 14th, 2009, 07:28 AM