手机程序出错an error occurred whileerror executing work

查询记录时报错:An error occurred while executing batch. Error message is: Non-negative number required.该怎么解决_Sql Server大全_优良自学吧 |
当前位置: >
> 查询记录时报错:An error occurred while executing batch. Error message is: Non-negative number required.该怎么解决优良自学吧提供查询记录时报错:An error occurred while executing batch. Error message is: Non-negative number required.该怎么解决,查询记录时报错:An error occurred while executing batch. Error message is: Non-negative number required.服务器在香港,开发人员在广州。通过专线连接。 在查询分析器里面执行SELECT语句时,如果数据量小查询记录时报错:An error occurred while executing batch. Error message is: Non-negative number required.服务器在香港,开发人员在广州。通过专线连接。
在查询分析器里面执行SELECT语句时,如果数据量小的话没问题,但如果数据量稍大一些时就会报错:
An & error & occurred & while & executing & batch. & Error & message & is: & Non-negative & number & required.
Parameter & name: & count
不知道是什么原因?------解决方案--------------------没遇到过,帮顶
------解决方案--------------------把語句貼出來看看
------解决方案--------------------我們公司和你們公司一樣的,服務器也在香港
------解决方案--------------------数据量大了吧,超时.乱提示的.
------解决方案--------------------select * from tbl_PrM_raw_PriceStrcture
這麼單純的語句,應不會有差錯啊
------解决方案--------------------如果只执行这句select * from tbl_PrM_raw_PriceStrcture 应该不会出现这种问题
Parameter name: count
你是不是有多个语句一起执行,而导致某个定义的变量无效执行出错。。
------解决方案--------------------怀疑是包loss
这个用抓包工具看一看(本文来自互联网,不代表搜站(/)的观点和立场)本站所有内容来自互联网,若本站收录的信息无意侵犯了贵司版权,请给我们来信(),我们会及时处理和回复,谢谢编辑推荐最近更新当前位置: →
→ SQLServer2008R2 附加数据库时报错 An exception occurred while executing a Transact-SQL statement or batch.
SQLServer2008R2 附加数据库时报错 An exception occurred while executing a Transact-SQL statement or batch.
& 作者及来源: zlb - 博客园 &
&收藏到→_→:
摘要: SQLServer2008R2 附加数据库时报错 An exception occurred while executing a Transact-SQL statement or batch.
"SQLServer2008R2 附加数据库时报错 An exception occurred while executing a Transact-SQL statement or batch."::
附加时报错 错误信息如下 an exception occurred while executing a transact-sql statement or batch. 详细信息 title: microsoft sql server management studio------------------------------ attach database failed for server 'lzhang136'.& (microsoft.sqlserver.smo) for help, click: /fwlink?prodname=microsoft+sql+server&prodver=10.50.1600.1+((kj_rtm).9+)&evtsrc=microsoft.sqlserver.management.smo.exceptiontemplates.failedoperationexceptiontext&evtid=attach+database+server&linkid=20476 ------------------------------additional information: an exception occurred while executing a transact-sql statement or batch. (microsoft.sqlserver.connectioninfo) ------------------------------ unable to open the physical file "e:\study\silverlight\all slfs10 session\slfs10 session 3 (wcf ria services) - code\wcfriaservices_firestarter\riaserviceswithrepositorydemo\bookshelf.web\app_data\aspnetdb.mdf". operating system error 5: "5(failed to retrieve text for this error. reason: 15105)". (microsoft sql server, error: 5120) for help, click: /fwlink?prodname=microsoft+sql+server&prodver=10.50.1600&evtsrc=mssqlserver&evtid=5120&linkid=20476 ------------------------------buttons: ok title: microsoft sql server management studio------------------------------ attach database failed for server 'lzhang136'.& (microsoft.sqlserver.smo) for help, click: /fwlink?prodname=microsoft+sql+server&prodver=10.50.1600.1+((kj_rtm).9+)&evtsrc=microsoft.sqlserver.management.smo.exceptiontemplates.failedoperationexceptiontext&evtid=attach+database+server&linkid=20476 ------------------------------additional information: an exception occurred while executing a transact-sql statement or batch. (microsoft.sqlserver.connectioninfo) ------------------------------ unable to open the physical file "f:\aspnetdb.mdf". operating system error 5: "5(failed to retrieve text for this error. reason: 15105)". (microsoft sql server, error: 5120) for help, click: /fwlink?prodname=microsoft+sql+server&prodver=10.50.1600&evtsrc=mssqlserver&evtid=5120&linkid=20476 ------------------------------buttons: ok & 解决方法:用windows用户登录,不要用sql用户登录搜索此文相关文章:时报错 An exception occurred while executing a Transact-SQL statement or batch.此文来自: 马开东博客
网址: 站长QQ
SQLServer2008R2 附加数据库时报错 An exception occurred while executing a Transact-SQL statement or batch._博客园相关文章
博客园_总排行榜
博客园_最新
博客园_月排行榜
博客园_周排行榜
博客园_日排行榜How to solve java.lang.RuntimeException error occured while executing doInBackground()? [如何解决. lang。RuntimeException错误发生在执行doInBackground()?] - 问题-字节技术
How to solve java.lang.RuntimeException error occured while executing doInBackground()?
如何解决. lang。RuntimeException错误发生在执行doInBackground()?
问题 (Question)
I am beginner in android development, I am getting error in following code. I am calling asyn method for http request, before that I am checking Wifi or Mobile Network is available or not. When Internet connection is available My Service is running fine but when in off line mode I ma getting this type of error:
" java.lang.RuntimeException: An error occured while executing doInBackground()"
04-09 19:44:33.057: E/AndroidRuntime(3127): FATAL EXCEPTION: AsyncTask #1
04-09 19:44:33.057: E/AndroidRuntime(3127): java.lang.RuntimeException: An error
occured while executing doInBackground()
04-09 19:44:33.057: E/AndroidRuntime(3127):
android.os.AsyncTask$3.done(AsyncTask.java:278)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.lang.Thread.run(Thread.java:856)
04-09 19:44:33.057: E/AndroidRuntime(3127): Caused by: java.lang.NullPointerException
04-09 19:44:33.057: E/AndroidRuntime(3127):
at com.zoomi_zdc.SERVICES.MyServiceProf$myPostData.doInBackground(MyServiceProf.java:129)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at com.zoomi_zdc.SERVICES.MyServiceProf$myPostData.doInBackground(MyServiceProf.java:1)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at android.os.AsyncTask$2.call(AsyncTask.java:264)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
Below is MyServiceProfile code. In this code first I am checking Internet connectivity and aftr tht If User is offline, data saved in local database and during Internet Connection automatically Update on our server
public class MyServiceProf extends Service {
Timer t = new Timer();
public TimerTask mTimerT
private ConnectivityManager connectivityM
final Handler handler = new Handler();
private int nCounter = 0;
Context context =
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
public void onCreate() {
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
mTimerTask = new TimerTask() {
public void run() {
handler.post(new Runnable() {
public void run() {
nCounter++;
connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
final android.net.NetworkInfo wifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
final android.net.NetworkInfo mobile = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if (wifi.isAvailable()) {
mTimerTask.cancel();
new myPostData().execute();
}catch (Exception e) {
// TODO: handle exception
} else if (mobile.isAvailable()) {
mTimerTask.cancel();
new myPostData().execute();
}catch (Exception e) {
// TODO: handle exception
Toast.makeText(getBaseContext(),"You are trying to access online content but Internet Connection has been disconnected!!!",Toast.LENGTH_SHORT).show();
Log.d("TIMER", "TimerTask run");
// public void schedule (TimerTask task, long delay, long period)
t.schedule(mTimerTask, 0, 10000); //
public void onDestroy() {
// TODO Auto-generated method stub
t.cancel();
handler.removeCallbacks(mTimerTask);
} catch (Exception e) {
// TODO: handle exception
Toast.makeText(getApplicationContext(), " Stopped", Toast.LENGTH_SHORT).show();
public class myPostData extends AsyncTask&Void, Void, Void& {
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
HttpProfilePost proupdate = new HttpProfilePost();
String mMyprofileImagename[] = DatabaseHalper.mStudentImgNm.get(0).split("/");
File sdcardPathofprofileimg = new File(Environment.getExternalStorageDirectory()+"/data/.System/MProfile/" +mMyprofileImagename[1]);
Bitmap mBitmapimageofMyProfilepic = BitmapFactory.decodeFile(sdcardPathofprofileimg.getAbsolutePath());
DatabaseHalper dbhelper = new DatabaseHalper(getBaseContext());
dbhelper.Get_ZoomiProfile_Data();
proupdate.HttpClient_Profile_Post(context,DatabaseHalper.mStudentRollNo.get(0),
DatabaseHalper.mStudentName.get(0),
DatabaseHalper.mStudentAddress.get(0),
DatabaseHalper.mStudentEmrg_Person.get(0),
DatabaseHalper.mStudentEmrg_No.get(0),
DatabaseHalper.mStudentEmail.get(0),
DatabaseHalper.mStudentBloodGrp.get(0),
DatabaseHalper.mStudentMobileno.get(0),
mBitmapimageofMyProfilepic);
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
My Update on server Http
link code is below:
public class HttpProfilePost {
private JSONObject jsonR
private Bitmap myP
private ByteArrayOutputS
private byte[]
/*private ByteArrayB
private MultipartEntity reqE*/
private InputS
private SharedPreferences mP
private SharedPreferences.Editor mE
private Context mC
private HttpResponse httpR
List&String&
private String image1,image2,image3,image4,image5,image6,image7,image8,image9,image10;
//private String WEBSERVICE_NAME = "Profile_post.aspx";
public JSONObject HttpClient_Profile_Post(Context c,String stud_rollno, String stud_name,String stud_address, String stud_emrgperson, String stud_emrgcontact, String stud_email, String stud_bloodgrp, String stud_mobileno, Bitmap myPhoto){
mContext=c;
mPref = PreferenceManager.getDefaultSharedPreferences(mContext);
HttpClient httpClient = new DefaultHttpClient();
String mStudentUserid= mPref.getString("Userid", "" );
String myImage[] = DatabaseHalper.mStudentImgNm.get(0).split("/");
String profileimagepath = myImage[0];
stud_name = URLEncoder.encode(stud_name);
stud_address = URLEncoder.encode(stud_address);
stud_emrgperson = URLEncoder.encode(stud_emrgperson);
stud_emrgcontact = URLEncoder.encode(stud_emrgcontact);
stud_email = URLEncoder.encode(stud_email);
stud_bloodgrp = URLEncoder.encode(stud_bloodgrp);
HttpPost mURL = new HttpPost("http://10.160.0.18:86/Service.svc/testpersondatapost?uid="+mStudentUserid+"&stdname="+stud_name+"&stdmail="+stud_email+"&Add="+stud_address+"&Qual=xyz&Qual_add=abc&pro_expert=abc&achieve=abc&Cont_no="+stud_mobileno+"&othr1=abc&othr2=abc&othr3=abc&proimgpath="+profileimagepath+"&UT=Student&Emer_ContPer="+stud_emrgperson+"&Emer_Cont_no="+stud_emrgcontact+"&Bld_Grp="+stud_bloodgrp+"&Addi_Notes"+;
String mURL = "http://webservice.zoomi.in/Service.svc/testpersondatapost?uid="+mStudentUserid+"&stdname="+stud_name+"&stdmail="+stud_email+"&Add="+stud_address+"&Qual=xyz&Qual_add=abc&pro_expert=abc&achieve=abc&Cont_no="+stud_mobileno+"&othr1=abc&othr2=abc&othr3=abc&proimgpath="+profileimagepath+"&UT=Student&Emer_ContPer="+stud_emrgperson+"&Emer_Cont_no="+stud_emrgcontact+"&Bld_Grp="+stud_bloodgrp+"&Addi_Notes=abc";
String mURL = "http://webservice.zoomi.in/Service.svc/testpersondatapost?uid="+mStudentUserid+"&stdname="+stud_name+"&stdmail="+stud_email+"&Add="+stud_address+"&Qual=xyz&Qual_add=abc&pro_expert=abc&achieve=abc&Cont_no="+stud_mobileno+"&othr1=abc&othr2=abc&othr3=abc&proimgpath="+profileimagepath+"&UT=Student&Emer_ContPer="+stud_emrgperson+"&Emer_Cont_no="+stud_emrgcontact+"&Bld_Grp="+stud_bloodgrp+"";
String mURL = "http://10.160.0.18:86/Service.svc/testpersondatapost?uid="+mStudentUserid+"&stdname="+stud_name+"&stdmail="+stud_email+"&Add="+stud_address+"&Qual=xyz&Qual_add=abc&pro_expert=abc&achieve=abc&Cont_no="+stud_mobileno+"&othr1=abc&othr2=abc&othr3=abc&proimgpath="+profileimagepath+"&UT=Student&Emer_ContPer="+stud_emrgperson+"&Emer_Cont_no="+stud_emrgcontact+"&Bld_Grp="+stud_bloodgrp+"";
HttpPost postrequest = new HttpPost(mURL);
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
FileBody fileBody = new FileBody(new File(Environment.getExternalStorageDirectory()+"/data/.System/MProfile/", myImage[1]));// ,"application/octet-stream");
reqEntity.addPart("fileContents", fileBody);
postrequest.setEntity(reqEntity);
// Execute the request "POST"
httpResp = httpClient.execute(postrequest);
/*HttpResponse response =*/
// Check the status code, in this case "created"
//Log.v("App", "Created");
int code = httpResp.getStatusLine().getStatusCode();
System.out.println("Response Code : "+code);
/*if (((HttpResponse) response).getStatusLine().getStatusCode() == HttpStatus.SC_CREATED)
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
int responcecode = httpResp.getStatusLine().getStatusCode();
if(responcecode==200)
Intent stopserviceintnet = new Intent(mContext,MyServiceProf.class);
mContext.stopService(stopserviceintnet);
System.out.print("Your service is stopped...");
MyclassFragment.mbtn_SaveMyProfile.setEnabled(true);
catch (Exception e) {
// TODO: handle exception
QuickaccessFragment.mbtn_SaveMyProfile.setEnabled(true);
catch (Exception e) {
// TODO: handle exception
System.out.print("Your service is running...");
System.out.println(jsonResponse);
return jsonR
Sometimes It works properly but suddenly my apps has been Crashed while wifi or Mobile Internet connection is connected, I think at that time service did not run properly. :(
Waiting for your suggestion, solution and your ideas.
我是初学者在android开发中,我在下面的代码错误。我打电话asyn http请求方法,在那之前我检查无线或移动网络是否可用。当网络连接可用服务正在运行好了但是我什么时候在脱机模式下马英九获得这种类型的错误:& . lang。RuntimeException:执行时出错doInBackground()”04-09 19:44:33.057: E/AndroidRuntime(3127): FATAL EXCEPTION: AsyncTask #1
04-09 19:44:33.057: E/AndroidRuntime(3127): java.lang.RuntimeException: An error
occured while executing doInBackground()
04-09 19:44:33.057: E/AndroidRuntime(3127):
android.os.AsyncTask$3.done(AsyncTask.java:278)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:273)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.util.concurrent.FutureTask.setException(FutureTask.java:124)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:307)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.lang.Thread.run(Thread.java:856)
04-09 19:44:33.057: E/AndroidRuntime(3127): Caused by: java.lang.NullPointerException
04-09 19:44:33.057: E/AndroidRuntime(3127):
at com.zoomi_zdc.SERVICES.MyServiceProf$myPostData.doInBackground(MyServiceProf.java:129)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at com.zoomi_zdc.SERVICES.MyServiceProf$myPostData.doInBackground(MyServiceProf.java:1)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at android.os.AsyncTask$2.call(AsyncTask.java:264)
04-09 19:44:33.057: E/AndroidRuntime(3127):
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
下面是MyServiceProfile代码。在这段代码中第一次我检查网络连接和aftr年中如果离线用户,数据保存在本地数据库,并在网络连接我们的服务器上自动更新public class MyServiceProf extends Service {
Timer t = new Timer();
public TimerTask mTimerT
private ConnectivityManager connectivityM
final Handler handler = new Handler();
private int nCounter = 0;
Context context =
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
public void onCreate() {
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
mTimerTask = new TimerTask() {
public void run() {
handler.post(new Runnable() {
public void run() {
nCounter++;
connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
final android.net.NetworkInfo wifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
final android.net.NetworkInfo mobile = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if (wifi.isAvailable()) {
mTimerTask.cancel();
new myPostData().execute();
}catch (Exception e) {
// TODO: handle exception
} else if (mobile.isAvailable()) {
mTimerTask.cancel();
new myPostData().execute();
}catch (Exception e) {
// TODO: handle exception
Toast.makeText(getBaseContext(),"You are trying to access online content but Internet Connection has been disconnected!!!",Toast.LENGTH_SHORT).show();
Log.d("TIMER", "TimerTask run");
// public void schedule (TimerTask task, long delay, long period)
t.schedule(mTimerTask, 0, 10000); //
public void onDestroy() {
// TODO Auto-generated method stub
t.cancel();
handler.removeCallbacks(mTimerTask);
} catch (Exception e) {
// TODO: handle exception
Toast.makeText(getApplicationContext(), " Stopped", Toast.LENGTH_SHORT).show();
public class myPostData extends AsyncTask&Void, Void, Void& {
protected void onPreExecute() {
// TODO Auto-generated method stub
super.onPreExecute();
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
HttpProfilePost proupdate = new HttpProfilePost();
String mMyprofileImagename[] = DatabaseHalper.mStudentImgNm.get(0).split("/");
File sdcardPathofprofileimg = new File(Environment.getExternalStorageDirectory()+"/data/.System/MProfile/" +mMyprofileImagename[1]);
Bitmap mBitmapimageofMyProfilepic = BitmapFactory.decodeFile(sdcardPathofprofileimg.getAbsolutePath());
DatabaseHalper dbhelper = new DatabaseHalper(getBaseContext());
dbhelper.Get_ZoomiProfile_Data();
proupdate.HttpClient_Profile_Post(context,DatabaseHalper.mStudentRollNo.get(0),
DatabaseHalper.mStudentName.get(0),
DatabaseHalper.mStudentAddress.get(0),
DatabaseHalper.mStudentEmrg_Person.get(0),
DatabaseHalper.mStudentEmrg_No.get(0),
DatabaseHalper.mStudentEmail.get(0),
DatabaseHalper.mStudentBloodGrp.get(0),
DatabaseHalper.mStudentMobileno.get(0),
mBitmapimageofMyProfilepic);
protected void onPostExecute(Void result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
}我的更新服务???的Http链接代码如下:public class HttpProfilePost {
private JSONObject jsonR
private Bitmap myP
private ByteArrayOutputS
private byte[]
/*private ByteArrayB
private MultipartEntity reqE*/
private InputS
private SharedPreferences mP
private SharedPreferences.Editor mE
private Context mC
private HttpResponse httpR
List&String&
private String image1,image2,image3,image4,image5,image6,image7,image8,image9,image10;
//private String WEBSERVICE_NAME = "Profile_post.aspx";
public JSONObject HttpClient_Profile_Post(Context c,String stud_rollno, String stud_name,String stud_address, String stud_emrgperson, String stud_emrgcontact, String stud_email, String stud_bloodgrp, String stud_mobileno, Bitmap myPhoto){
mContext=c;
mPref = PreferenceManager.getDefaultSharedPreferences(mContext);
HttpClient httpClient = new DefaultHttpClient();
String mStudentUserid= mPref.getString("Userid", "" );
String myImage[] = DatabaseHalper.mStudentImgNm.get(0).split("/");
String profileimagepath = myImage[0];
stud_name = URLEncoder.encode(stud_name);
stud_address = URLEncoder.encode(stud_address);
stud_emrgperson = URLEncoder.encode(stud_emrgperson);
stud_emrgcontact = URLEncoder.encode(stud_emrgcontact);
stud_email = URLEncoder.encode(stud_email);
stud_bloodgrp = URLEncoder.encode(stud_bloodgrp);
HttpPost mURL = new HttpPost("http://10.160.0.18:86/Service.svc/testpersondatapost?uid="+mStudentUserid+"&stdname="+stud_name+"&stdmail="+stud_email+"&Add="+stud_address+"&Qual=xyz&Qual_add=abc&pro_expert=abc&achieve=abc&Cont_no="+stud_mobileno+"&othr1=abc&othr2=abc&othr3=abc&proimgpath="+profileimagepath+"&UT=Student&Emer_ContPer="+stud_emrgperson+"&Emer_Cont_no="+stud_emrgcontact+"&Bld_Grp="+stud_bloodgrp+"&Addi_Notes"+;
String mURL = "http://webservice.zoomi.in/Service.svc/testpersondatapost?uid="+mStudentUserid+"&stdname="+stud_name+"&stdmail="+stud_email+"&Add="+stud_address+"&Qual=xyz&Qual_add=abc&pro_expert=abc&achieve=abc&Cont_no="+stud_mobileno+"&othr1=abc&othr2=abc&othr3=abc&proimgpath="+profileimagepath+"&UT=Student&Emer_ContPer="+stud_emrgperson+"&Emer_Cont_no="+stud_emrgcontact+"&Bld_Grp="+stud_bloodgrp+"&Addi_Notes=abc";
String mURL = "http://webservice.zoomi.in/Service.svc/testpersondatapost?uid="+mStudentUserid+"&stdname="+stud_name+"&stdmail="+stud_email+"&Add="+stud_address+"&Qual=xyz&Qual_add=abc&pro_expert=abc&achieve=abc&Cont_no="+stud_mobileno+"&othr1=abc&othr2=abc&othr3=abc&proimgpath="+profileimagepath+"&UT=Student&Emer_ContPer="+stud_emrgperson+"&Emer_Cont_no="+stud_emrgcontact+"&Bld_Grp="+stud_bloodgrp+"";
String mURL = "http://10.160.0.18:86/Service.svc/testpersondatapost?uid="+mStudentUserid+"&stdname="+stud_name+"&stdmail="+stud_email+"&Add="+stud_address+"&Qual=xyz&Qual_add=abc&pro_expert=abc&achieve=abc&Cont_no="+stud_mobileno+"&othr1=abc&othr2=abc&othr3=abc&proimgpath="+profileimagepath+"&UT=Student&Emer_ContPer="+stud_emrgperson+"&Emer_Cont_no="+stud_emrgcontact+"&Bld_Grp="+stud_bloodgrp+"";
HttpPost postrequest = new HttpPost(mURL);
MultipartEntity reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
FileBody fileBody = new FileBody(new File(Environment.getExternalStorageDirectory()+"/data/.System/MProfile/", myImage[1]));// ,"application/octet-stream");
reqEntity.addPart("fileContents", fileBody);
postrequest.setEntity(reqEntity);
// Execute the request "POST"
httpResp = httpClient.execute(postrequest);
/*HttpResponse response =*/
// Check the status code, in this case "created"
//Log.v("App", "Created");
int code = httpResp.getStatusLine().getStatusCode();
System.out.println("Response Code : "+code);
/*if (((HttpResponse) response).getStatusLine().getStatusCode() == HttpStatus.SC_CREATED)
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
int responcecode = httpResp.getStatusLine().getStatusCode();
if(responcecode==200)
Intent stopserviceintnet = new Intent(mContext,MyServiceProf.class);
mContext.stopService(stopserviceintnet);
System.out.print("Your service is stopped...");
MyclassFragment.mbtn_SaveMyProfile.setEnabled(true);
catch (Exception e) {
// TODO: handle exception
QuickaccessFragment.mbtn_SaveMyProfile.setEnabled(true);
catch (Exception e) {
// TODO: handle exception
System.out.print("Your service is running...");
System.out.println(jsonResponse);
return jsonR
}有时它能正常工作,但突然我的应用程序已经坠毁无线或移动互联网连接连接,当时我觉得服务不正常运行。(等待你的建议,解决方案和你的想法。谢谢。
最佳答案 (Best Answer)
04-09 19:44:33.057: E/AndroidRuntime(3127): Caused by: java.lang.NullPointerException
04-09 19:44:33.057: E/AndroidRuntime(3127):
at com.zoomi_zdc.SERVICES.MyServiceProf$myPostData.doInBackground(MyServiceProf.java:129)
according to those 2 lines you have a Null pointer at line 129 of your code.
Go to that line, check what is being done, find the object that is null and fix it.
That's debugging 101.
04-09 19:44:33.057: E/AndroidRuntime(3127): Caused by: java.lang.NullPointerException
04-09 19:44:33.057: E/AndroidRuntime(3127):
at com.zoomi_zdc.SERVICES.MyServiceProf$myPostData.doInBackground(MyServiceProf.java:129)
答案 (Answer) 2
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
mTimerTask = new TimerTask() {
public void run() {
nCounter++;
connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
final android.net.NetworkInfo wifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
final android.net.NetworkInfo mobile = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if (wifi.isAvailable()) {
mTimerTask.cancel();
new myPostData().execute();
}catch (Exception e) {
// TODO: handle exception
} else if (mobile.isAvailable()) {
mTimerTask.cancel();
new myPostData().execute();
}catch (Exception e) {
// TODO: handle exception
Toast.makeText(getBaseContext(),"You are trying to access online content but Internet Connection has been disconnected!!!",Toast.LENGTH_SHORT).show();
Log.d("TIMER", "TimerTask run");
// public void schedule (TimerTask task, long delay, long period)
t.schedule(mTimerTask, 0, 10000); //
remove handler() in your service .. you will not get this error again.. please make changes in your code as follows.
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
mTimerTask = new TimerTask() {
public void run() {
nCounter++;
connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
final android.net.NetworkInfo wifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
final android.net.NetworkInfo mobile = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
if (wifi.isAvailable()) {
mTimerTask.cancel();
new myPostData().execute();
}catch (Exception e) {
// TODO: handle exception
} else if (mobile.isAvailable()) {
mTimerTask.cancel();
new myPostData().execute();
}catch (Exception e) {
// TODO: handle exception
Toast.makeText(getBaseContext(),"You are trying to access online content but Internet Connection has been disconnected!!!",Toast.LENGTH_SHORT).show();
Log.d("TIMER", "TimerTask run");
// public void schedule (TimerTask task, long delay, long period)
t.schedule(mTimerTask, 0, 10000); //
本文翻译自StackoverFlow,英语好的童鞋可直接参考原文:

我要回帖

更多关于 error executing work 的文章

 

随机推荐