Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
String membertype = "";//登录用户类型
try {
StringBuffer sb = new StringBuffer();
sb.append(" select membertype from m_b_broker where brokerid='"+logonUser+"' ");
System.out.print(sb);
rs = stmt.executeQuery(sb.toString()); //这里报出空指针异常
System.out.print("1111");
while (rs.next()) {
membertype=rs.getString("membertype");
}
rs.close();
rs = null;
stmt.close();
stmt = null;
conn.close();
conn = null;
}
catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (rs != null) {
rs.close();
rs = null;
}
if (stmt != null) {
stmt.close();
stmt = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
return membertype;
是别的文件有问题 这个项目的jar包和写法不是正常的jdbc
Statement stmt = null;
你的Statement 没有初始化啊
Connection conn=DriverManager.getConnection();
。。。。
。。。。
stateMent state=conn.createStateMent();
.......
.......