Class.forName"com.microsoft.jdbc.sqlserver.SQLServerDriver");
少了一个(
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
去掉ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE
就是为Statement stmt=conn.createStatement();
就可以了

解决方案 »

  1.   

    stmt.executeQuery===>stmt.executeUpdate(...
      

  2.   

    你在catch(SQLException e){}里面用e.printStackTrace()把错误栈全部打印出来。看一看是连接数据库的哪一步出错了。
    你的数据库查询语句没有问题,问题很可能出在对数据库的操作权限上。你到SQL Server的security里选项里选上数据库验证和系统验证两种方式均可登陆。
      

  3.   

    上面说的catch(SQLException e)应该是cathc(Exception e)。
    其实写程序的时候不应该catch一个Exception了事,应该把每个可能抛出的具体的Exception都catch一下,并进行处理。
      

  4.   

    class.forName少个括号......stmt.executeQuery("insert into userinfo values('asd','asdf','f','21')");应该改成
    stmt.executeUpdate("....");..........catch中间是SQLException ................