大家帮我看一下一下这个程序:                                                                                                                                             try{   
command="create table Student1(number char(10),name char(20),sex char(4),age char(3),class char(10),major char(10))";
stat=con.createStatement();
stat.executeUpdate(command);
System.out.println("OK:表已经建立");
BufferedReader in=new BufferedReader(new FileReader("student.dat"));
String line=null;
while((line=in.readLine())!=null){
command="insert into student values("+line+")";
stat.executeUpdate(command);
}
System.out.println("表已填充好!");
command="create view stu_view(number,name) as select number,name from student";
stat.executeUpdate(command);
System.out.println("视图已经建立");
}                                                                         student.dat内的内容为:                                                             02020719,'林龙强','男',19,0120307,'计算机'
03010827,'蒋毅','男',20,0110308,'计算机'
04010411,'陈杰','男',19,0110404,'自动化'
05160102,'王金娥','女',21,0620501,'计算机'
05160103,'皮鸿娟','女',20,0620501,'自动化'
05160104,'王晓琳','女',19,0620501,'自动化' 

解决方案 »

  1.   

     你的表有6个字段你的insert sql 是不是 也有相应的6个字段呢 command="insert into student values("+line+")";
    System.out.println(command);加上红色这句看看日志  改sql就ok 了
      

  2.   

    insert into student values(02020719,'林龙强','男',19,0120307,'计算机')
    SQLException:
    [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]插入错误: 列名或所提供值的数目与表定义不匹配。
    只能插入一行,又出现了异常
      

  3.   

    insert into student values('02020719','林龙强','男',19,'0120307','计算机') 这样写
      

  4.   

    你字段定义的全部是char,那插入的数据也应该全部是char,不能用int的.