Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8461043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:46:15+00:00 2026-06-10T13:46:15+00:00

And here is my rest code @Path(Users) public class ItemsResource extends stu{ @Context private

  • 0

And here is my rest code

@Path("Users")
public class ItemsResource extends stu{

  @Context
  private UriInfo context;

  /**
   * Creates a new instance of ItemsResource
   */
  public ItemsResource() {
  }

  /**
   * Retrieves representation of an instance of service.ItemsResource
   * @return an instance of java.lang.String
   */
  @GET
  @Produces("text/plain")
  public String getText() {
      //TODO return proper representation object
      throw new UnsupportedOperationException();
  }

  /**
   * POST method for creating an instance of ItemResource
   * @param content representation for the new resource
   * @return an HTTP response with content of the created resource
   */
   @POST
   @Consumes("text/plain")
   @Produces("text/plain")
   public Response postText(@PathParam("id") int id,@PathParam("Password") String Password,
                        @PathParam("Username") String Username) {
    //TODO

       super.createText(id,Password,Username);
       return Response.created(context.getAbsolutePath()).build();
      // return "success";
   }
  /**
   * Sub-resource locator method for {id}
   */   
}

here is stu.java

class stu {

     public String createText(int id,String Username,String Password) {
        //TODO
       try 
       {
          Class.forName("com.mysql.jdbc.Driver");
          Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/users","root","789456");

          String query=  "Insert into users (id,username,password) values('"+id+"','"+Username+"','"+Password+"')";
          PreparedStatement stm = con.prepareStatement(query);         

          stm.executeUpdate(query);
        } catch(ClassNotFoundException e){
           System.err.println ("Sql Exception"+e);
        } catch(SQLException e){
           System.err.println ("Sql Exception"+e);
        }

    return "success";
  } 
}

Now when i test rest and post data it is successfully posted but it does not get updated in database kindly tell me my error

the REST response is as

Request: POST localhost:8090/WebApplication16/resources/Users?
timestamp=1346152551629

Status: 201 (Created)

Time-Stamp: Tue, 28 Aug 2012 11:15:51 GMT

Sent:
1,hey,hdhb

Received:


-----------------------------------------------------------------------

Request: localhost:8090/WebApplication16/resources/application.wadl


Status: 200 (OK)

Time-Stamp: Tue, 28 Aug 2012 11:15:41 GMT

Received:

<?xml version="1.0" encoding="UTF-8"?>
   <application xmlns="research.sun.com/wadl/2006/10">
       <doc xmlns:jersey="jersey.dev.java.net/" jersey:generatedBy="Jersey: 1.5 01/14/2011 12:36 PM"/>
       <resources base="localhost:8090/WebApplication16/resources/">
           <resource path="Users">
               <param xmlns:xs="www.w3.org/2001/XMLSchema" name="id" style="template" type="xs:int"/>
               <param xmlns:xs="www.w3.org/2001/XMLSchema" name="Username" style="template" type="xs:string"/>
               <param xmlns:xs="http://www.w3.org/2001/XMLSchema" name="Password" style="template" type="xs:string"/>
               <method id="getText" name="GET">
                   <response>
                       <representation mediaType="text/plain"/>
                   </response>
               </method>
               <method id="postText" name="POST">
                   <response>
                       <representation mediaType="text/plain"/>
                   </response>
               </method>
           </resource>
       </resources>
   </application> 

And it is able to contact my database and a new row is created in table but with null,null,null values. Kindly help me out in this.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T13:46:17+00:00Added an answer on June 10, 2026 at 1:46 pm

    I think the data is not “successfully posted”. You use the @PathParam annotation when you have the parameters in your @Path, like @Path("Users/{id}").

    How are you sending the parameters? If you send them with a browser and a POST <form>, try to use the @FormParam annotation. See this question for more information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the view: @if (stream.StreamSourceId == 1) { <img class=source src=@Url.Content(~/Public/assets/images/own3dlogo.png) alt= /> }
First some code: import java.util.*; //... class TicTacToe { //... public static void main
Please see the attached image: 1) I downloaded a new library here: ( http://www.java2s.com/Code/Jar/ABC/Downloadcommonslang24jar.htm
There is a talk here by Stefan Tilkov , where he is describing REST
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is the code in a function I'm trying to revise. This example works
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
Im having a little problem with classes. Here is some of my code: //GameMap.h
currently here is my code NSFileManager *fileManager = [[NSFileManager alloc] init]; BOOL receiptExists =
When communicating with our REST webservice, an http response with status code of 304

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.