当前位置:编程学习 > JAVA >>

求大神赐教 [Microsoft][ODBC Microsoft Access Driver] 参数不足,期待是 1。怎么处理

package 学生;
import java.sql.*;  
public class FoundData
 {   /**   * @param args   */
public static final String db_driver="sun.jdbc.odbc.JdbcOdbcDriver";  
    public static final String db_url="jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ=d:/Student.mdb";

      
    public static void main(String args[]){  
    
     try{
     String sql="select*from Stu where 学号=201211013";
    
            Class.forName(db_driver);  
            Connection conn=DriverManager.getConnection(db_url,"",""); 
            if(conn!=null){  
                System.out.println("数据库已连接.....");  
            }else{  
                System.out.println("连接失败!");  
            }  
            Statement stmt=conn.createStatement();
            ResultSet rs=stmt.executeQuery(sql);
            String r1="insert into Stu values("+"'李四','201211011','男','12',地球)";
            System.out.println(r1);
            stmt.executeUpdate(r1);
            while(rs.next())
            { 
              System.out.print(rs.getString("姓名")+'\t');
                 System.out.print(rs.getString("学号")+'\t');
                 System.out.print(rs.getString("性别")+'\t');
                 System.out.print(rs.getString("地址")+'\t');
                 System.out.println(rs.getString("年龄")+'\t');
            
            }
            stmt.close();
            conn.close();

            
        }catch(Exception e){  
            e.printStackTrace();  
        }  
    }  
}  
补充:Java ,  Java相关
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,