本帖最后由 wswg15 于 2018-1-7 08:31 编辑
各位大神:
大家好,求助,如题。
参考网上一个用户注册登录模块:
1)用户名和密码只能是数字才能注册或登录;
2)不注册时,用户名和密码随意输入数字,会弹出“用户名和密码不对”,但输入字母,就直接闪退了。
不注册时,用户名输入"a",密码输入“1”,闪退,调试码如下:
01-07 08:30:05.057 20031-20031/com.example.foolishfan.user_v10 I/UserDataManager: UserDataManager construc
tion!
01-07 08:30:11.924 20031-20031/com.example.foolishfan.user_v10 I/UserDataManager: findUserByNameAndPwd
01-07 08:30:11.924 20031-20031/com.example.foolishfan.user_v10 E/SQLiteLog: (1) no such column: a
01-07 08:30:11.925 20031-20031/com.example.foolishfan.user_v10 D/AndroidRuntime: Shutting down VM
01-07 08:30:11.926 20031-20031/com.example.foolishfan.user_v10 E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.foolishfan.user_v10, PID: 20031
android.database.sqlite.SQLiteException: no such column: a (code 1): , while compiling: SELECT * FROM users WHERE user_name=a and user_pwd=1
at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:887)
at android.database.sqlite.SQLiteConnection.prepare(SQLiteConnection.java:498)
at android.database.sqlite.SQLiteSession.prepare(SQLiteSession.java:588)
at android.database.sqlite.SQLiteProgram.
(SQLiteProgram.java:58)
at android.database.sqlite.SQLiteQuery.(SQLiteQuery.java:37)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:44)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1316)
at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1163)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1034)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1202)
at com.example.foolishfan.user_v10.UserDataManager.findUserByNameAndPwd(UserDataManager.java:151)
at com.example.foolishfan.user_v10.Login.login(Login.java:122)
at com.example.foolishfan.user_v10.Login$1.onClick(Login.java:94)
at android.view.View.performClick(View.java:5207)
at android.view.View$PerformClick.run(View.java:21177)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5438)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:629)
01-07 08:30:11.948 20031-20031/com.example.foolishfan.user_v10 I/Process: Sending signal. PID: 20031 SIG: 9
请大神帮忙下!谢谢了。