问答详情
源自:2-3 JDBC实战---搭建模型层 Ⅰ

报这个错是为啥Exception in thread "main" java.lang.NullPointerException at com.spring.dao.Goddess_dao.query(Goddess_dao.java:28) at com.spring.action.GoddessAction.main(GoddessAction.java:10)

package com.spring.action;

import java.util.List;


import com.spring.dao.*;

import com.spring.model.Goddess;

public class GoddessAction {


public static void main(String[] args) throws Exception {

Goddess_dao g = new Goddess_dao();

List<Goddess> gs = g.query();

for (Goddess goddess : gs) {

System.out.println(goddess.getUser_name()+","+goddess.getAge());

}

}

}



提问者:worstcoder 2016-09-20 19:55

个回答

  • 过客2015_YY
    2016-09-22 11:25:50
    已采纳

    因为 你使用g.query();这里面

    Goddess_dao.java:28

    报空指针异常,需要贴出代码

  • 947412344
    2016-10-10 10:59:51

    我也出现了这个问题你是怎么处理的啊?