java.lang.NullPointerException,文本导入sql server时异常
Connection con = null;
ResultSet rs = null;
Statement smt = null;
try
{
con = ConnectionManager.getConnection();
// 将用户上行记录存入userinput表中
String sql= "insert into userinput from " + file + " with (fieldterminator= ', ',rowterminator= '\n ') ";
smt.executeUpdate(sql);
smt.close();smt=null;
con.close();con=null;
}
catch(Exception e)
{
try{if(smt!=null) smt.close();}catch(SQLException sqle){}
try{if(con!=null) con.close();}catch(SQLException sqle){}
}
------解决方法--------------------------------------------------------
smt.executeUpdate(sql);
这个smt你就没创建,怎么能用呢,不NullPointerException才怪
smt=con.createStatement();