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 8426417
In Process

The Archive Base Latest Questions

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

Hi i have to develop the app is insert the database from spinner in

  • 0

Hi i have to develop the app is insert the database from spinner in mysql database via soap webserices in android application…

i have use below webservice code:

public class Insertion {

 public String insertData(String userName,String userPassword){

 try{

 Class.forName("com.mysql.jdbc.Driver");
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/androidlogin","root","");
 PreparedStatement statement =  con.prepareStatement("INSERT INTO user(status) VALUES ('"+userName+"');");
  int result = statement.executeUpdate();
   }

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

      return "Insertion successfull!!";
      }

   }

i have use below code for android spinner example:

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


    btninsert = (Button)findViewById(R.id.btn_insert);  
    btninsert.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
         insertValues();
        }
    });
  }

  public void insertValues(){


    SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
    Spinner userName = (Spinner) findViewById(R.id.spnMusketeers);
    List<String> lsMusketeers = new ArrayList<String>();
    lsMusketeers.add("Q");
    lsMusketeers.add("P");
    lsMusketeers.add("C");

    ArrayAdapter<String> aspnMusketeers = 
      new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, 
       lsMusketeers);
    aspnMusketeers.setDropDownViewResource
       (android.R.layout.simple_spinner_dropdown_item);
    spnMusketeers.setAdapter(aspnMusketeers);

// Set up a callback for the spinner
   spnMusketeers.setOnItemSelectedListener(
    new OnItemSelectedListener() {
        public void onNothingSelected(AdapterView<?> arg0) { }

        public void onItemSelected(AdapterView<?> parent, View v, 
         int position, long id)  {

          // Code that does something when the Spinner value changes
        }

    });
    String user_Name = userName.getContext().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);


         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){

      } 
       // Code that does something when the Spinner value changes
     }
     }

Here how is change my code for this question.

my logcat window says:

  08-23 02:48:40.030: D/AndroidRuntime(4055): Shutting down VM
  08-23 02:48:40.030: W/dalvikvm(4055): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
  08-23 02:48:40.060: E/AndroidRuntime(4055): FATAL EXCEPTION: main
  08-23 02:48:40.060: E/AndroidRuntime(4055): java.lang.NullPointerException
  08-23 02:48:40.060: E/AndroidRuntime(4055):   at com.android.soap.InsertionExample.insertValues(InsertionExample.java:63)
   08-23 02:48:40.060: E/AndroidRuntime(4055):  at com.android.soap.InsertionExample$1.onClick(InsertionExample.java:43)
   08-23 02:48:40.060: E/AndroidRuntime(4055):  at android.view.View.performClick(View.java:2408)
    08-23 02:48:40.060: E/AndroidRuntime(4055):     at android.view.View$PerformClick.run(View.java:8816)
   08-23 02:48:40.060: E/AndroidRuntime(4055):  at android.os.Handler.handleCallback(Handler.java:587)
   08-23 02:48:40.060: E/AndroidRuntime(4055):  at android.os.Handler.dispatchMessage(Handler.java:92)
   08-23 02:48:40.060: E/AndroidRuntime(4055):  at android.os.Looper.loop(Looper.java:123)
  08-23 02:48:40.060: E/AndroidRuntime(4055):   at android.app.ActivityThread.main(ActivityThread.java:4627)
  08-23 02:48:40.060: E/AndroidRuntime(4055):   at java.lang.reflect.Method.invokeNative(Native Method)
   08-23 02:48:40.060: E/AndroidRuntime(4055):  at java.lang.reflect.Method.invoke(Method.java:521)
   08-23 02:48:40.060: E/AndroidRuntime(4055):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
    08-23 02:48:40.060: E/AndroidRuntime(4055):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
   08-23 02:48:40.060: E/AndroidRuntime(4055):  at dalvik.system.NativeStart.main(Native Method)

please help me….what error is occurred here.give me solution…

  • 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-10T04:31:48+00:00Added an answer on June 10, 2026 at 4:31 am

    use this code for this insert function:

    String selectedItem = parent.getItemAtPosition(pos).toString();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to develop an android app for which I have to use camera
I am new in Android. I have develop an app. And now want to
I have to develop web2py app and have to use Facebook sdk in that.
I have to develop an App for Android tablets that demands printing files to
I want to develop an Android app in which I have key log press.
I have an app that I want to develop for Android 2.1, 2.2, 2.3.3,
For my schoolproject I have to develop an Android app that continuously tracks the
I develop app for android. I test it on many devices but I have
I have develop an Android app, this app through a Apache Client send latitude
I have to develop an Android app for NFC enabled Android Devices, If both

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.