主题:为什么老是参数不足,期待是1的错误?
为什么老是出现 (java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] 参数不足,期待是 1) 希望大家指导。谢谢!(附件里是我所操作的表)非常感谢!
import java.sql.*;
public class Update
{ public static void main(String args[])
{
Connection con;
Statement sql;
ResultSet rs;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){}
try{
con=DriverManager.getConnection("jdbc:odbc:album","kcsj","qhh");
sql=con.createStatement();
int CategoryID=2,AlbumID;
String AlbumPath="path2",AlbumName,recode,updateStr,insertStr,delStr;
updateStr="UPDATE Albums SET AlbumPath="+AlbumPath+" WHERE CategoryID='+CategoryID+'";
AlbumName="伦敦";
CategoryID=3;
AlbumPath="path3";
recode="("+"'"+AlbumName+"'"+","+"'"+CategoryID+"'"+","+"'"+AlbumPath+"'"+")";
insertStr="INSERT INTO Albums VALUE S"+recode;
delStr="DELETE FROM Albums WHERE AlbumPath='path4'";
sql.executeUpdate(updateStr);
sql.executeUpdate(insertStr);
sql.executeUpdate(delStr);
rs=sql.executeQuery("SELECT*FROM Albums");
while(rs.next())
{
AlbumID=rs.getInt("AlbumID");
AlbumName=rs.getString(1);
AlbumPath=rs.getString(2);
System.out.print("AlbumID:"+AlbumID);
System.out.print(" AlbumName:"+AlbumName);
System.out.println(" AlbumPath:"+AlbumName);
}
con.close();
}
catch(SQLException e)
{
System.out.println(e);
}
}
}
import java.sql.*;
public class Update
{ public static void main(String args[])
{
Connection con;
Statement sql;
ResultSet rs;
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){}
try{
con=DriverManager.getConnection("jdbc:odbc:album","kcsj","qhh");
sql=con.createStatement();
int CategoryID=2,AlbumID;
String AlbumPath="path2",AlbumName,recode,updateStr,insertStr,delStr;
updateStr="UPDATE Albums SET AlbumPath="+AlbumPath+" WHERE CategoryID='+CategoryID+'";
AlbumName="伦敦";
CategoryID=3;
AlbumPath="path3";
recode="("+"'"+AlbumName+"'"+","+"'"+CategoryID+"'"+","+"'"+AlbumPath+"'"+")";
insertStr="INSERT INTO Albums VALUE S"+recode;
delStr="DELETE FROM Albums WHERE AlbumPath='path4'";
sql.executeUpdate(updateStr);
sql.executeUpdate(insertStr);
sql.executeUpdate(delStr);
rs=sql.executeQuery("SELECT*FROM Albums");
while(rs.next())
{
AlbumID=rs.getInt("AlbumID");
AlbumName=rs.getString(1);
AlbumPath=rs.getString(2);
System.out.print("AlbumID:"+AlbumID);
System.out.print(" AlbumName:"+AlbumName);
System.out.println(" AlbumPath:"+AlbumName);
}
con.close();
}
catch(SQLException e)
{
System.out.println(e);
}
}
}