title: insert spinner value in mysql db via soap ws in android
body: <p>Hi i have to develop the app is insert the database from spinner in mysql database via soap webserices in android application... </p>
  
  <p>i have use below webservice code:</p>
  
  <pre><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!!";
        }
  
     }
  </code></pre>
  
  <p>i have use below code for android spinner example:</p>
  
  <pre><code>  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&lt;String&gt; lsMusketeers = new ArrayList&lt;String&gt;();
      lsMusketeers.add("Q");
      lsMusketeers.add("P");
      lsMusketeers.add("C");
  
      ArrayAdapter&lt;String&gt; aspnMusketeers = 
        new ArrayAdapter&lt;String&gt;(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&lt;?&gt; arg0) { }
  
          public void onItemSelected(AdapterView&lt;?&gt; 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
       }
       }
  </code></pre>
  
  <p>Here how is change my code for this question.</p>
  
  <p>my logcat window says:</p>
  
  <pre><code>  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)
  </code></pre>
  
  <p>please help me....what error is occurred here.give me solution...</p>