java.sql.SQLException: [Microsoft][ODBC Microsoft Access 驱动程序] 参数不足,期待是 3。
importjava.sql.*;publicclassStudentInfoModify{publicstaticvoidmain(String[]args){Conn...
import java.sql.*;
public class StudentInfoModify
{
public static void main(String[] args)
{
Connection con;
Statement stmt;
ResultSet rs;
String sql;
String number,name;
int speciality;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){}
try
{
con=DriverManager.getConnection("jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=E:/实训课/电商1401马仲涛/ECStudent.mdb","","");
stmt=con.createStatement();
sql="update StudentInfo set Speciality=电机与电气 where Number='10ZD140115'";
int m=stmt.executeUpdate(sql);
rs=stmt.executeQuery("select * from StudentInfo");
while(rs.next())
{
String Number=rs.getString(2);
String Name=rs.getString(3);
String Speciality=rs.getString(7);
System.out.print("学号:"+Number+"\t");
System.out.print("姓名:"+Name+"\t");
System.out.print("专业:"+Speciality+"\t");
}
con.close();
}
catch(SQLException e)
{ System.out.println(e);}
}
} 展开
public class StudentInfoModify
{
public static void main(String[] args)
{
Connection con;
Statement stmt;
ResultSet rs;
String sql;
String number,name;
int speciality;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){}
try
{
con=DriverManager.getConnection("jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=E:/实训课/电商1401马仲涛/ECStudent.mdb","","");
stmt=con.createStatement();
sql="update StudentInfo set Speciality=电机与电气 where Number='10ZD140115'";
int m=stmt.executeUpdate(sql);
rs=stmt.executeQuery("select * from StudentInfo");
while(rs.next())
{
String Number=rs.getString(2);
String Name=rs.getString(3);
String Speciality=rs.getString(7);
System.out.print("学号:"+Number+"\t");
System.out.print("姓名:"+Name+"\t");
System.out.print("专业:"+Speciality+"\t");
}
con.close();
}
catch(SQLException e)
{ System.out.println(e);}
}
} 展开
2个回答
2016-06-20
展开全部
参数不足,可能是字段名写错了了 。。。。。。。。
追问
找不到啊
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询