Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC & Access

 
Minh Phan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear friends
,
I have written a Java class to insert 01 record into a table in an Access database.
But when I ran my compiled class it threw an error. I send the .java file as well as the .mdb file to you. Please correct the problem. Thank you!



Best regards

[Edited to disable smilies and add UBB code tags. To do this yourself next time, smilies can be disabled at the bottom of the edit screen and the code tags are right below the editing textbox.]
[ September 23, 2004: Message edited by: Jeanne Boyarsky ]
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i m not gonna read your code. please send the error first.
 
Ramaswamy Srinivasan
Ranch Hand
Posts: 295
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

It is a good practice to give the error. With that error as the base,
there won't be a necessity for code to fix the error. Without knowing the error, It would be very difficult for anyone to go thru the code, compile it and find the error.

What if they don't a database, that you are using? So, if u can plz specify the error that you encounter, prolly someone can look ito that.

Cheers,
Swamy
 
Minh Phan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The error was too few arguements, expected: 4
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
do e.printStackTrace() and then paste it here. it might help us.
 
Roberto Spier
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Minh

your sql expression

String query = "Insert book Values(bc, bc, ba, baq)";

should pass the variable's values, not it's names. Thus, the parameters expected message.

Try something like

String query = "Insert book Values('" + bc + "', '" + bn + "', '" + ba + "', " + baq + ")";
System.out.println(query); // this should looks like your commented line below
//String query = "Insert into book Values ('AAA','BBB','CCC',1)";

hth (and my english makes sense)
 
Minh Phan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Roberto Spier, your trick has worked!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic