java - How to connect to mysql with eclipse in android -
I am trying to connect to the MySQL database in Android Eclipse and my SQL-connector-Java-3.1.12- I am also using bin. But it shows me the message: Failure due to the underlying exception and it is not connected yet I am using the same thing to connect to my Java programs in NetBeans. Any help would be appreciated.
Package com.bookapp; You can not connect mysql database to Android to call you database You can use webservices. Some examples for webservices are SOAP and RESTFUL. You can use one of these to make WCB calls. To call the caller, see the following example: You can use SQL Lite to create mini db in Android. Google on SQL Lite to get more information import java.sql.SQLException; Importroid.os.Bundle; Import android.view.View; Import android.view.View.OnClickListener; Import android.widget.Button; Import android.widget.EditText; Android Import; Spinner; Import android.widget.Toast; Import android App Import android.content.Intent; Public class enhances PersiansIno activity (protected void onCreate) (bundled saved instenstate) {super.onCreate (savedInstanceState); SetContentView (R.layout.personalinfo); Try {StudentDA Promotion = New Student (); For (string jshdjsd: stud.GetAllUniversities ()) {Toast TT = Toast. Make text (personal info., Jshdjsd, toast.ln.gov_LOG); Tt.show (); } // for eastud.GetAllUniversities ())); } Catch (SS) {Toast TT = Toast. Maketext (Personality Info.), "You Have an Error" + Asmessage (), Toast. LNNHHLOG); Tt.show (); } // Replace layout widget / control button Button btnNext = (button) findViewById (R.id.btnNext); // Textbox references the last edit text; // Text Box Final Spinner CMG Andender = (Spinner) Find VVBIID (RID CMGZender); // combo box txtStudNo = (EditText) findViewById (R.id.txtStudentNo); TxtName = (EditText) findViewById (R.id.txtName); TxtSurname = (edit text) findViewById (R.id.txtSurname); // button onclick event listener set btnNext.setOnClickListener (New OnClickListener) {@Override Public Zero Click on (see ARG0) {// TODO Auto generated stub stub if (txtStudNo.getText () .toString (). "Toast TT = Toast. Maketext (Personal Info.this," Please enter student no. ", Toast. LNGH_LAG); TT show ();} and if (TTNTNMTest)")) (Toast TT = Toast. Maketext (Private Inf. This, "Please enter the name", Toast. LNG H.L.L.G.); tt.show ();} and if (txtSurname.gettext () .toString (.) Equals (")) (Toast TT = Toast. Maketext (" Personal Info "," Please Entry Entry ", Toast. LNNGH_LAG); TT Show ();} And if (CMGender Gate Selective Iotposion () == 0) {Toast TT = Toast MakeText (PersonalInfo.this, "Please select gender", Toast.LangthaLong); Show ();} other {student.grader = CMGender.getSactedIightum (). ToString (); Student.Student n = txtStudNo.getText () To String (); Student.Name = txtName.getText (). ToString (); student. Name = txtSurname.getText (). ToString (); // Go to next RM Intent I = New Intent (PersonalInfo.this, ContactInfo.class); StartActivity (i); /////// The next // Toast TT = Toast Make Text (Personal Info., "Thank you", + Student., Toast. LNNHHLOG); // tt.show (); }}}); }}
Comments
Post a Comment