aspose file tools*
The moose likes JDBC and the fly likes JDBC & Access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC & Access" Watch "JDBC & Access" New topic
Author

JDBC & Access

Minh Phan
Greenhorn

Joined: Sep 23, 2004
Posts: 8
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

Joined: Aug 15, 2004
Posts: 2874
i m not gonna read your code. please send the error first.
Ramaswamy Srinivasan
Ranch Hand

Joined: Aug 31, 2004
Posts: 295
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

Joined: Sep 23, 2004
Posts: 8
The error was too few arguements, expected: 4
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
do e.printStackTrace() and then paste it here. it might help us.
Roberto Spier
Greenhorn

Joined: Sep 13, 2004
Posts: 7
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

Joined: Sep 23, 2004
Posts: 8
Thank you, Roberto Spier, your trick has worked!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC & Access