부울 기능을 사용하여 로그인 활동을 만들고 있지만 전자 메일 주소와 데이터베이스의 전자 메일 주소가 일치하지만 오류가 발생하는 동안 오류가 발생합니다."@gmail"근처 구문 오류
이 내 dbHandler
클래스 방법 :
public Boolean loginCheck(String email,String password)
{
Boolean flag=false;
String selectQuery = "SELECT * FROM " + TABLE_NAME + " WHERE email=" + email +" AND pass="+password;
SQLiteDatabase db = this.getReadableDatabase();
Cursor cursor = db.rawQuery(selectQuery, null);
// Move to first row
cursor.moveToFirst();
if(cursor.getCount() == 1){
flag=true;
}
else
{
flag=false;
}
return flag;
}
이것이 자바 파일의 코드
login.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
String emailValue=edtEmail.getText().toString();//this is EditText
String passValue=edtPass.getText().toString();
if(db.loginCheck(emailValue, passValue))
{
Intent in = new Intent(getApplicationContext(), Home.class);
startActivity(in);
Toast.makeText(getApplicationContext(), "Login Successful", 2000).show();
}
else
{
Toast.makeText(getApplicationContext(), "Username and Password not match", 5000).show();
}
}
});
가져 오기 오류
01-23 04:58:30.519: E/AndroidRuntime(2422): android.database.sqlite.SQLiteException: near "@gmail": syntax error (code 1): , while compiling: SELECT * FROM login WHERE [email protected] AND pass=stackoverflow
01-23 04:58:30.519: E/AndroidRuntime(2422): at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
01-23 04:58:30.519: E/AndroidRuntime(2422): at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:882)
제공하십시오 솔루션 그것의
매개 변수를 이스케이프 처리해야합니다. 'rawQuery' 대신'query'를 사용하고'email' 매개 변수를 전달하십시오. – 323go