アンドロイドでSQL Serverからテーブルローをフェッチしていますが、プログレスバーに表示したいのですが問題があります。テーブル行の長さを取ることを許さない..my接続クラス。SQL Serverからアンドロイドでテーブル行をダウンロード中に進行状況バーを表示
String ip="192.168.43.85";
String classs="net.sourceforge.jtds.jdbc.Driver";
String db="mydatabasename";
String uname="myname";
String pass="pass";
@SuppressLint("New Api")
public Connection CON() throws IOException{
StrictMode.ThreadPolicy policy=new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Connection connection=null;
String ConUrl=null;
try {
Class.forName(classs);
ConUrl="jdbc:jtds:sqlserver://"+ip+";"
+ "databaseName="+db+";user="+uname+";password="
+pass+";";
connection= DriverManager.getConnection(ConUrl);
} catch (ClassNotFoundException e) {
Log.e("ERRO",e.getMessage());
} catch (SQLException e) {
Log.e("ERROR",e.getMessage());
} catch (Exception e) {
Log.e("ERROr", e.getMessage());
}
return connection;
}
私はGoogleからのいくつかの例を試してみましたが、すべての例は、HTTPおよびURLを使用していますが、私は長さを見つけるために、URLを持っていません。
Connection conn = null;
try {
conn = connectionClass.CON();
} catch (IOException e) {
e.printStackTrace();
}
if (conn == null) {
Toast.makeText(getApplicationContext(), "Error in Connection with server.Make sure your internet connection is ON", Toast.LENGTH_SHORT).show();
} else {
Statement stmt = null;
try {
//String Slqquery = "select * from Zmat";
String Slqquery1 = "select GlobalSummaryReportFlag,StudyID,StoreCode,StudyDesc from GlobalCountSummaryReport where GlobalSummaryReportFlag='1' and StudyId='" + strStudyId1 + "' and StoreCode='" + strStudyCode2 + "' and StudyDesc='" + strStudyDes3 + "'";
stmt = conn.createStatement();
ResultSet rs3;
rs3 = stmt.executeQuery(Slqquery1);
if (rs3.next()) {
progress1=new ProgressDialog(MenuActivity.this);
progress1.setMessage("Downloading GC");
progress1.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
progress1.setIndeterminate(true);
progress1.setProgress(0);
progress1.setMax(100);
progress1.show();
final int totalProgressTime = 100;
new Thread(new Runnable() {
@Override
public void run() {
int jumpTime = 0;
while(jumpTime < totalProgressTime) {
try {
Data();
if (countForHireMapping == 0 || CountForArticle == 0) {
Toast.makeText(getApplicationContext(), "Downloaded UnSuccessfully Please Retry", Toast.LENGTH_SHORT).show();
delete2();
progress1.dismiss();
} else {
sleep(200);
jumpTime += 5;
progress1.setProgress(jumpTime);
progress1.dismiss();
Intent intent = new Intent(MenuActivity.this, LocationActivity.class);
startActivity(intent);
Toast.makeText(getApplicationContext(), "Downloaded Successfully", Toast.LENGTH_SHORT).show();
}
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}).start();
} else {
Toast.makeText(getApplicationContext(), "Gc Not Completed", Toast.LENGTH_SHORT).show();
}
} catch (SQLException e) {
e.printStackTrace();
}
}`