我知道我有一个空指针,但不知道它在哪里发生或为什么发生。希望在这里得到一些帮助。
Button add = (Button) findViewById(R.id.addfencebutton);
add.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View add) {
//code to store in fence locations database
createData();
}
});
}
public void createData(){
Course course = new Course();
course.setcoursename("courseNamefield");
course.setfencename("fenceNamefield");
course.setAlocation("standardAfield");
course.setBlocation("standardBfield");
course = datasource.create(course);
Log.i(course.getcoursename(), null);
//Log.i("course created with id" + course.getcourseid(), null);
// Log.i("course name is " + course.getcoursename(), null);
}
文件courseDBopenHelper
public class courseDBOpenHelper extends SQLiteOpenHelper {
private static final String LOGTAG = "courseDatabase";
private static final String DATABASE_NAME = "courses.db";
private static final int DATABASE_VERSION = 1;
public static final String TABLE_COURSES = "courses";
public static final String COLUMN_ID = "coursesID";
public static final String COLUMN_COURSENAME = "coursename";
public static final String COLUMN_FENCENAME = "fencename";
public static final String COLUMN_ALOCATION = "alocation";
public static final String COLUMN_BLOCATION = "blocation";
private static final String TABLE_CREATE =
"CREATE TABLE " + TABLE_COURSES + " (" +
COLUMN_ID + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
COLUMN_COURSENAME + " TEXT, " +
COLUMN_FENCENAME + " TEXT, " +
COLUMN_ALOCATION + " NUMERIC, " +
COLUMN_BLOCATION + " NUMBERIC " +
")";
public courseDBOpenHelper(Context context) {
super(context, DATABASE_NAME, null, DATABASE_VERSION);
}
@Override
public void onCreate(SQLiteDatabase db) {
db.execSQL(TABLE_CREATE);
Log.i(LOGTAG, "table created");
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
db.execSQL("DROP TABLE IF EXISTS" + TABLE_COURSES);
onCreate(db);
}
}
courseDataSource.java
public class courseDataSource {
public static final String LOGTAG = "courseDatabase";
SQLiteOpenHelper dbhelper;
SQLiteDatabase database;
public courseDataSource(Context context) {
dbhelper = new courseDBOpenHelper(context);
database = dbhelper.getWritableDatabase();
}
public void open(){
Log.i(LOGTAG, "database open");
database = dbhelper.getWritableDatabase();
}
public void close(){
Log.i(LOGTAG, "database closed");
dbhelper.close();
}
public Course create(Course course) {
ContentValues values = new ContentValues();
values.put(courseDBOpenHelper.COLUMN_COURSENAME, course.getcourseid());
values.put(courseDBOpenHelper.COLUMN_FENCENAME, course.getcoursename());
values.put(courseDBOpenHelper.COLUMN_ALOCATION, course.getAlocation());
values.put(courseDBOpenHelper.COLUMN_BLOCATION, course.getBlocation());
long insertid = database.insert(courseDBOpenHelper.TABLE_COURSES, null, values);
course.setcourseid(insertid);
return course;
}
}
course.java
public class Course {
private long courseid;
private String coursename;
private String fencename;
private String Alocation;
private String Blocation;
public long getcourseid(){
return courseid;
}
public void setcourseid(long courseid) {
this.courseid = courseid;
}
public String getcoursename(){
return coursename;
}
public void setcoursename(String string){
this.coursename = coursename;
}
public String getfencename(){
return fencename;
}
public void setfencename(String fencename){
this.fencename = fencename;
}
public String getAlocation(){
return Alocation;
}
public void setAlocation(String view){
this.Alocation = view;
}
public String getBlocation(){
return Blocation;
}
public void setBlocation(String view){
this.Blocation = view;
}
}
错误日志
02-27 11:03:42.058: E/AndroidRuntime(909): FATAL EXCEPTION: main
02-27 11:03:42.058: E/AndroidRuntime(909): java.lang.NullPointerException: println needs a message
02-27 11:03:42.058: E/AndroidRuntime(909): at android.util.Log.println_native(Native Method)
02-27 11:03:42.058: E/AndroidRuntime(909): at android.util.Log.i(Log.java:159)
02-27 11:03:42.058: E/AndroidRuntime(909): at com.greygoosefarmpa.fencecoursebuilder.addFence.createData(addFence.java:155)
02-27 11:03:42.058: E/AndroidRuntime(909): at com.greygoosefarmpa.fencecoursebuilder.addFence$4.onClick(addFence.java:140)
02-27 11:03:42.058: E/AndroidRuntime(909): at android.view.View.performClick(View.java:4202)
02-27 11:03:42.058: E/AndroidRuntime(909): at android.view.View$PerformClick.run(View.java:17340)
02-27 11:03:42.058: E/AndroidRuntime(909): at android.os.Handler.handleCallback(Handler.java:725)
02-27 11:03:42.058: E/AndroidRuntime(909): at android.os.Handler.dispatchMessage(Handler.java:92)
02-27 11:03:42.058: E/AndroidRuntime(909): at android.os.Looper.loop(Looper.java:137)
02-27 11:03:42.058: E/AndroidRuntime(909): at android.app.ActivityThread.main(ActivityThread.java:5039)
02-27 11:03:42.058: E/AndroidRuntime(909): at java.lang.reflect.Method.invokeNative(Native Method)
02-27 11:03:42.058: E/AndroidRuntime(909): at java.lang.reflect.Method.invoke(Method.java:511)
02-27 11:03:42.058: E/AndroidRuntime(909): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
02-27 11:03:42.058: E/AndroidRuntime(909): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
02-27 11:03:42.058: E/AndroidRuntime(909): at dalvik.system.NativeStart.main(Native Method)
你的错误很明显
E/AndroidRuntime(909): java.lang.NullPointerException: println needs a message 02-27 11:03:42.058:
您必须为日志消息提供一条消息。不能为空。
Log.i(course.getcoursename(), null);
应该
Log.i(course.getcoursename(), "Some not null string");
由于芹菜是作业队列/任务队列,因此名称说明了它可以维护其任务并处理它们。那么为什么它需要像rabbymq或redis这样的消息代理呢?
问题内容: 通过Rabbitmq中的示例,消费者可以一次从队列中获取所有消息。如何使用一条消息并退出? 问题答案: 您必须声明basicQos设置,才能一次从ACK到NACK状态获取一条消息,并禁用自动ACK以便显式给出确认。 希望能帮助到你!
我创建了一个简单的项目,带有Spring Boot和JOOQ,添加了依赖项“spall-boot-starter-jooq”。当我编译时,应用程序无法启动。 以下是pom.xml: 这就是我想要注入上下文的地方: 错误消息: 上下文初始化期间遇到异常-取消刷新尝试:org。springframework。豆。工厂UnsatisfiedPendencyException:创建名为“gameDao”的
我用spring boot和JOOQ创建了一个简单的项目,添加了依赖项“spring-boot-starter-jooq”。编译时应用程序启动失败。 下面是pom.xml: 这就是我要注入DSLContext的地方: 应用程序启动失败 /****************************** 描述:com.bingo.api.dao.Gamedao中的构造函数的参数0需要一个类型为“org.
我在第一页“login.php”中有这个 日志php: 如果我测试第一个页面“login.php”,我会得到: 警告:require_once(1):无法打开流:C:\xampp\htdocs\admin\login中没有此类文件或目录。php第6行 致命错误:require_once():无法在C:\xampp\htdocs\admin\login中打开所需的“1”(include_path=”
我有一个警告脚本,你基本上警告duh,它工作,但每次它发送一个不需要的消息 这是我的剧本 我很确定这是一个错误,但我只是想确定我在这里问过它,任何帮助都是感激的