将文本文件导入到sql server数据库中,但是在导入数据库时出现了异常,在tomcat中打印出的异常提示为“java.lang.NullPointerException”

将文本文件导入到sql server数据库中,但是在导入数据库时出现了错误,在tomcat中打印出的错误提示为“java.lang.NullPointerException”,
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();
------解决方案--------------------
楼上正解~