大家好我在使用jtds驱动程序进行数据库。
但我有一个问题,我无法解决它。问题是:
java.lang.RuntimeException: An error occured while executing doInBackground()
at android.os.AsyncTask$3.done(AsyncTask.java:299)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:352)
at java.util.concurrent.FutureTask.setException(FutureTask.java:219)
at java.util.concurrent.FutureTask.run(FutureTask.java:239)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.VerifyError: net/sourceforge/jtds/jdbc/TdsCore
at net.sourceforge.jtds.jdbc.JtdsConnection.<init>(JtdsConnection.java:359)
at net.sourceforge.jtds.jdbc.Driver.connect(Driver.java:184)
at java.sql.DriverManager.getConnection(DriverManager.java:179)
at java.sql.DriverManager.getConnection(DriverManager.java:144)
at com.verimbt.elmacafeplus.SignupActivity.connectionclass(SignupActivity.java:244)
at com.verimbt.elmacafeplus.SignupActivity$RegisterLogin.doInBackground(SignupActivity.java:184)
at com.verimbt.elmacafeplus.SignupActivity$RegisterLogin.doInBackground(SignupActivity.java:144)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
... 4 more
我可以做什么我检查到处但我无法发现任何错误正在开发但用户从Android 4.3版本报告此错误...我正在使用5.0.1版本我不会给出任何错误...
SignUpActivity.class
public class SignupActivity extends AppCompatActivity {
// Declaring connection variables
int registerednew=0;
Connection con;
protected String un,pass,db,ip;
//End Declaring connection variables
//Database den çekilen değerlerin lokalleri
String Name;
String Surname;
String Gsm;
int KategoriID;
String QRCodeID;
int OnayID;
String Email;
int UserID;
String Password;
///////////////////////////////////////////////
ProgressDialog progressDialog;
private static final String TAG = "SignupActivity";
@Bind(R.id.input_name) EditText _nameText;
@Bind(R.id.input_surname) EditText _surnameText;
@Bind(R.id.input_email) EditText _emailText;
@Bind(R.id.input_gsm) EditText _gsmText;
@Bind(R.id.input_password) EditText _passwordText;
@Bind(R.id.btn_signup) Button _signupButton;
@Bind(R.id.link_login) TextView _loginLink;
String saveddbpass;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_signup);
ButterKnife.bind(this);
EditText cepno=(EditText) findViewById(R.id.input_gsm);
// Declaring Server ip, username, database name and password
ip = ********
db =*******
un = ********
pass = *********;
SharedPreferences prefs = new LoginManager(this, this.getSharedPreferences("Myshared", Context.MODE_PRIVATE));
prefs.edit().putString("Pass",pass);
saveddbpass=prefs.getString("Pass",pass);
// Declaring Server ip, username, database name and password
// Listening to Login Screen link
cepno.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_SEND) {
signup();
handled = true;
}
return handled;
}
});
_signupButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
signup();
}
});
_loginLink.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Finish the registration screen and return to the Login activity
finish();
}
});
}
public void signup() {
Log.d(TAG, "Signup");
if (!validate()) {
onSignupFailed();
return;
}
_signupButton.setEnabled(false);
String name = _nameText.getText().toString();
String surname = _surnameText.getText().toString();
String email = _emailText.getText().toString();
String password = _passwordText.getText().toString();
String gsm = _gsmText.getText().toString();
// Closing registration screen
// Switching to Login Screen/closing activity_register screen
new RegisterLogin().execute(email,password,name,gsm,surname);
new android.os.Handler().postDelayed(
new Runnable() {
public void run() {
// On complete call either onSignupSuccess or onSignupFailed
// depending on success
onSignupSuccess();
// onSignupFailed();
}
}, 1000);
}
public class RegisterLogin extends AsyncTask<String,String,String>
{
String z ;
Boolean isSuccess = false;
@Override
protected void onPostExecute(String z)
{
Toast.makeText(SignupActivity.this, z, Toast.LENGTH_SHORT).show();
if(isSuccess)
{
progressDialog = new ProgressDialog(SignupActivity.this,
R.style.AppTheme_Dark_Dialog);
progressDialog.setIndeterminate(true);
progressDialog.setMessage("Creating Account...");
progressDialog.show();
progressDialog.dismiss();
Toast.makeText(SignupActivity.this , "Kayıt İşlemi Tamamlandı,Şimdi giriş yapabilirsiniz." , Toast.LENGTH_SHORT).show();
finish();
}
}
@Override
protected String doInBackground(String... args)
{
String Email2 =args[0];
String pass2=args[1];
String Name2 = args[2];
String Gsm2 = args[3];
String Surname2=args[4];
String QrCode;
if(Email2.trim().equals("")|| pass2.trim().equals(""))
z = "Please enter Username and Password";
else
{
try
{
con = connectionclass(un, saveddbpass, db, ip); // Connect to database
if (con == null)
{
z = "Check Your Internet Access!";
}
else
{
Calendar c = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("yyyy");
SimpleDateFormat df2 = new SimpleDateFormat("ddmm");
SimpleDateFormat df3 = new SimpleDateFormat("dd/MM/yyyy");
int hour = c.get(Calendar.HOUR_OF_DAY);
int minute = c.get(Calendar.MINUTE);
int second = c.get(Calendar.SECOND);
String formattedDate = df.format(c.getTime());
String formattedDate2 = df2.format(c.getTime());
String KayitTarihi = df3.format(c.getTime())+" "+hour+":"+minute+":"+second;
QrCode=formattedDate+Gsm2+formattedDate2;
Log.i("qrcode",QrCode);
// Change below query according to your own database.
String query = "insert into elmacustomers(KayitTarihi,QRCodeID,Gsm,Name,Surname,Email,Password,OnayID) VALUES('"+KayitTarihi+"',"+"'"+ QrCode.toString()+"',"+"'"+Gsm2.toString()+"',"+"'"+Name2.toString()+"','"+Surname2.toString()+"','"+Email2.toString()+"','"+pass2.toString()+"',"+"0) ";
Statement stmt = con.createStatement();
try {
stmt.executeUpdate(query);
} catch (SQLException e) {
z=Email2+" E-mail adresi sistemde kayitlidir";
onPause();
}
z="Kayıt İşlemi Tamamlandı,Şimdi giriş yapabilirsiniz.";
Intent i = new Intent(getApplicationContext(), LoginActivity.class);
i.putExtra("Email", Email);
i.putExtra("Pass", pass2);
i.putExtra("flag",0);
setResult(Activity.RESULT_OK,i);
finish();
}
}
catch (Exception ex)
{
isSuccess = false;
}
}
return z;
}
}
@SuppressLint("NewApi")
public Connection connectionclass(String user, String password, String database, String server)
{
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Connection connection = null;
String ConnectionURL = null;
try
{
Class.forName("net.sourceforge.jtds.jdbc.Driver");
ConnectionURL = "jdbc:jtds:sqlserver://" + server +"/"+ database + ";user=" + user+ ";password=" + password + ";";
connection = DriverManager.getConnection(ConnectionURL);
}
catch (SQLException se)
{
Log.e("error here 1 : ", se.getMessage());
}
catch (ClassNotFoundException e)
{
Log.e("error here 2 : ", e.getMessage());
}
catch (Exception e)
{
Log.e("error here 3 : ", e.getMessage());
}
return connection;
}
public void onSignupSuccess() {
_signupButton.setEnabled(true);
setResult(RESULT_OK, null);
finish();
}
public void onSignupFailed() {
Toast.makeText(getBaseContext(), "Login failed", Toast.LENGTH_LONG).show();
_signupButton.setEnabled(true);
}
public boolean validate() {
boolean valid = true;
String name = _nameText.getText().toString();
String email = _emailText.getText().toString();
String password = _passwordText.getText().toString();
if (name.isEmpty() || name.length() < 3) {
_nameText.setError("at least 3 characters");
valid = false;
} else {
_nameText.setError(null);
}
if (email.isEmpty() || !android.util.Patterns.EMAIL_ADDRESS.matcher(email).matches()) {
_emailText.setError("enter a valid email address");
valid = false;
} else {
_emailText.setError(null);
}
if (password.isEmpty() || password.length() < 4 || password.length() > 10) {
_passwordText.setError("between 4 and 10 alphanumeric characters");
valid = false;
} else {
_passwordText.setError(null);
}
return valid;
}
}