Android——Tomcat+MySQL+Servlet,实现将Client传入的数据写入MySQL

Android客户端将用户的注册信息上传到Tomcat Web服务器,Servlet将注册信息写入到MySQL中。

1,准备工作

(1)在MySQL中创建好要使用的数据库和数据表。
(2)设置好Tomcat的数据库连接池。

参见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"
            
评论 11
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值