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

  • SEARCH
  • Home
  • 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 8297917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T15:34:40+00:00 2026-06-08T15:34:40+00:00

Hi i have develop insert the values to mysql database.here i did not enter

  • 0

Hi i have develop insert the values to mysql database.here i did not enter the detail after click the button means that empty values also inserted.so please help me.how is validate here.
dis is my code:

  public class RegisterActivity extends Activity{
private final String NAMESPACE = "http://xcart.com";
private final String URL = "http://192.168.1.168:8085/XcartLogin/services/Insert?wsdl";
private final String SOAP_ACTION = "http://xcart.com/insertData";
private final String METHOD_NAME = "insertData";
Button btninsert;
private Button btn_cancel;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.register);

    btninsert = (Button)findViewById(R.id.btn_insert);

    btninsert.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
         insertValues();
         EditText userName = (EditText) findViewById(R.id.editText1);
         if( userName.getText().toString().trim().equals(""))
         {    
           userName.setError( "username is required!" );
           //You can Toast a message here that the Username is Empty
         }
         EditText userPassword = (EditText) findViewById(R.id.editText2);
         if( userPassword.getText().toString().trim().equals(""))
         {    
             userPassword.setError( "password is required!" );
           //You can Toast a message here that the Username is Empty
         }
        else
        {
           Intent i = new Intent(getApplicationContext(), AndroidLoginExampleActivity.class);
           startActivity(i);
        }


             }
         });




}
public void insertValues(){
 SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
 EditText userName = (EditText) findViewById(R.id.editText1);
 String user_Name = userName.getText().toString();



 EditText userPassword = (EditText) findViewById(R.id.editText2);
 String user_Password = userPassword.getText().toString();


 //Pass value for userName variable of the web service
    PropertyInfo unameProp =new PropertyInfo();
    unameProp.setName("userName");//Define the variable name in the web service method
    unameProp.setValue(user_Name);//Define value for fname variable
    unameProp.setType(String.class);//Define the type of the variable
    request.addProperty(unameProp);//Pass properties to the variable

  //Pass value for userPassword variable of the web service
    PropertyInfo passwordProp =new PropertyInfo();
    passwordProp.setName("userPassword");
    passwordProp.setValue(user_Password);
    passwordProp.setType(String.class);
    request.addProperty(passwordProp);

    SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
    envelope.setOutputSoapObject(request);
    HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

    try{
     androidHttpTransport.call(SOAP_ACTION, envelope);
        SoapPrimitive response = (SoapPrimitive)envelope.getResponse();

        TextView result = (TextView) findViewById(R.id.textView2);
        result.setText(response.toString());

 }
 catch(Exception e){

 }

}

 }.

Webservice code is:

package com.xcart;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;

public class Insert {

public String insertData(String userName,String userPassword){

try{

  Class.forName("com.mysql.jdbc.Driver");
  Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/xcart-432pro","root","");
  PreparedStatement statement =  con.prepareStatement("INSERT INTO xcart_customers(login,password) VALUES ('"+userName+"','"+userPassword+"');");
  int result = statement.executeUpdate();
  }

  catch(Exception exc){
  System.out.println(exc.getMessage());
  }

  return "Insertion successfull!!";
  }

  }

Please help me.

  • 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-08T15:34:43+00:00Added an answer on June 8, 2026 at 3:34 pm

    define this EditText userName = (EditText) findViewById(R.id.editText1); only once in oncreate, and use them all over the activity. In you code you are calling insertValues() method and u are inserting values without checking empty string in this method. that is the reason.

    your code should like as given below

    public class RegisterActivity extends Activity{
    
     EditText userName, userPassword ;  // << changes here
    private final String NAMESPACE = "http://xcart.com";
    private final String URL = "http://192.168.1.168:8085/XcartLogin/services/Insert?wsdl";
    private final String SOAP_ACTION = "http://xcart.com/insertData";
    private final String METHOD_NAME = "insertData";
    Button btninsert;
    private Button btn_cancel;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.register);
    
        btninsert = (Button)findViewById(R.id.btn_insert);
      user name = (EditText) findViewById(R.id.editText1);// << changes here
    userPassword = (EditText) findViewById(R.id.editText2);// << changes here
    
        btninsert.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
    
    
             if( userName.getText().toString().trim().equals(""))
             {    
               userName.setError( "username is required!" );
               //You can Toast a message here that the Username is Empty
             }
             EditText 
             if( userPassword.getText().toString().trim().equals(""))
             {    
                 userPassword.setError( "password is required!" );
               //You can Toast a message here that the Username is Empty
             }
            else
            {   insertValues();  // << changes here
               Intent i = new Intent(getApplicationContext(), AndroidLoginExampleActivity.class);
               startActivity(i);
            }
    
    
                 }
             });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to develop a application (Winforms-application) which is connected to a database within
I have to develop a database for a unique environment. I don't have experience
I have develop one simple database application build using SilverLight5.0 + Entity Framework +
I am having some problem here. I am trying to develop a flash database
I have develop one web site in php. I know how to upload it
Hi i have develop and deploy one multilingual (english uk and swedish) website at
I am new in Android. I have develop an app. And now want to
I have to develop an Intensity Meter, which will basically display the average intensity
I have to develop a program where I need to get the event from
I have to develop a simple parser, to read block of text for example:

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.