NullPointerException是可能性最多的异常了,你应该贴代码
Connection conn = null;
try {
String driver = "com.mysql.jdbc.Driver"; // 数据库驱动
String url = "jdbc:MySQL://127.0.0.1:3306/dbname";// 数据库
String user = "root"; // 用户名
String password = "hadoop"; // 密码
Class.forName(driver); // 加载数据库驱动
if (null == conn) {
conn = DriverManager.getConnection(url, user, password);
}
} catch (ClassNotFoundException e) {
System.out.println("Sorry,can't find the Driver!");
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
就是这一段,你应该debug一下,在哪一行崩掉的