需要从SQL Server获取一些数据并将其显示到textview中

时间:2018-03-21 14:27:17

标签: android sql-server

我需要从我的数据库中获取数据这里是我获取数据的代码

Connect.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view){
                try{
                    Connection con = connectionClass.CONN();
                    String query = "SELECT * FROM Driver WHERE UID='" + UID + "'";
                    Statement stmt = con.prepareStatement(query);
                    ResultSet rs = stmt.executeQuery(query);
                    while (rs.next()) {
                        UDI = rs.getString("FirstName");
                        TextView Name = (TextView) findViewById(R.id.name);
                        Name.setText(UDI);
                    }
                }
                catch (Exception ex)
                {

                }
            }
        });

问题是,每当我点击按钮时,都没有提取任何内容。

0 个答案:

没有答案