android에서 SQL Server의 테이블 행을 가져오고 진행 표시 줄에 표시하고 싶습니다. 문제가 발생합니다. SQL 연결 클래스를 사용하고 있습니다. 테이블 row.my 연결 클래스의 길이를 허용하지 않습니다. android에서 SQL 서버에서 테이블 행을 다운로드하는 동안 progress bar를 표시합니다.
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;
}
나는 구글에서 몇 가지 예를 시도했지만 모든 예제는 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();
}
}`