android连接阿里云mysql后闪退

显示网络未连接之后退出程序

public class connect {
    public static Connection getConnection(String dbName) throws SQLException {
        Connection conn = null;
        try {
            Class.forName("com.mysql.jdbc.Driver"); //加载驱动
            String ip = "rm-bp1t9js01f765a35k2o.mysql.rds.aliyuncs.com";
            conn =(Connection) DriverManager.getConnection(
                    "jdbc:mysql://" + ip + ":3306/" + dbName,
                    "zp_x", "Zpx008102");
            MainActivity.conn_on=1;//用于向主函数传参,判断连接是否成功
        }catch (SQLException | ClassNotFoundException ex) {
            ex.printStackTrace();
            MainActivity.conn_on=2;//用于向主函数传参,判断连接是否成功
        }
        return conn;//返回Connection型变量conn用于后续连接
    }

    final EditText username = (EditText) findViewById(R.id.IDinput);//取得输入框的对象
    final EditText password = (EditText) findViewById(R.id.code_input);

    final TextView conn = (TextView) findViewById(R.id.conn);//取得网络提示框的对象
    conn.setBackgroundColor(Color.RED);//默认设成红色
    final Handler handler = new Handler(new Handler.Callback() {
        @Override
        public boolean handleMessage(Message message) {
            switch (conn_on)//根据返回值判断网络连接是否成功
            {
                case 1:conn.setText("网络连接成功");conn.setBackgroundColor(Color.GREEN);break;
                case 2:conn.setText("网络连接失败");break;
            }
            return false;
        }
    });

String ip = "rm-bp1t9js01f765a35k2o.mysql.rds.aliyuncs.com"
改为
String ip = "jdbc:mysql://rm-bp1t9js01f765a35k2o.mysql.rds.aliyuncs.com?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false"

不能盲猜呀,你要去调试,或者看下logcat给你的错误提示。

mysql登录闪退-和mysql登录闪退相关的内容-阿里云开发者社区 阿里云开发者社区为开发者提供和mysql登录闪退相关的文章,如:mysql4.5 更改密码,登录命令行闪退mysql输入密码后闪退怎么办?、APP安全测试 该如何渗透检测APP存在的漏洞等开发者相关内容,如果您想查找和主从式操作系统出现异常怎么办、像素处理器出现问题怎么解决、去中心化网络42什么意思相关的内容,查看开发者相关的文章,欢迎来阿里云开发者社区 https://developer.aliyun.com/articlezt/6482392-1.html?spm=a2c4e.11155472