A database operation problems!

Category: Java SE
 
ccaa2
2008-09-21 07:54:25

Sponsored Links
Just learning java database operations, I use Access, using a method to insert data into the database, as follows:
public void Insertdate (int number, String name) {
try {
stmt.executeUpdate ("insert into st (ID, name) values ​​(" + number + "," + name + " ;) ");
/ / offectedRow = stmt.executeUpdate (" insert into st (ID, name) values ​​(4, 'vvv') ");
}
catch (Exception e) {
System.out.println ("An exception occurred while inserting data");
System.out.println (e);
}

but this method is called when such an exception:
java.sql.SQLException: [Microsoft ] [ODBC Microsoft Access Driver] Not enough arguments, expectations are one.
What kind of reason?

Sponsored Links

aiwoba3000
2008-09-21 08:00:23
stmt.executeUpdate ("insert into st (ID, name) values ​​(" + number + ", '" + name + "')");

seems to be two less'';
zhou124421
2008-09-21 08:15:42
change it stmt.executeUpdate ("insert into st ([ID], [name]) ; values ​​("+ number +", '"+ name +"') ");

id, name for Access is key, String value to add''

zzd6807
2008-09-21 08:34:45
Thank you both, the problem is this!
Thank you!
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.