Android客户端将用户的注册信息上传到Tomcat Web服务器,Servlet将注册信息写入到MySQL中。
1,准备工作
(1)在MySQL中创建好要使用的数据库和数据表。
(2)设置好Tomcat的数据库连接池。
2,Android客户端Activity和Layout的设计
(1)一个简单的注册界面,sign_layout.xml
sign_layout.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusableInTouchMode="true"
android:background="#ff6699cc"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fffffffb"
android:orientation="horizontal"
android:padding="40dp" >
<EditText
android:id="@+id/etSgAccount"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="20dp"
android:hint="@string/Account"
android:inputType="textEmailAddress" />
<EditText
android:id="@+id/etSgPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"