This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Need help with insert values into access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Need help with insert values into access" Watch "Need help with insert values into access" New topic
Author

Need help with insert values into access

Almog mar
Greenhorn

Joined: Nov 28, 2010
Posts: 3
I need help with this code:







I try to insert value into table in access but i dont succed...
I using with Eclipse.

You can fix my code for me?
I click on the botton NEXT and its no add the Name into the access...
Its add frame0.


Thanks you.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

There is a bug in the jdbc-odbc bridge. Try running a select on the same connection then see if the insert went through.
Almog mar
Greenhorn

Joined: Nov 28, 2010
Posts: 3
David O'Meara wrote:There is a bug in the jdbc-odbc bridge. Try running a select on the same connection then see if the insert went through.



I dont understand...
This code: String sql="INSERT INTO RECIPESTABLE(RECIPENAME,INGREDIENTS)"+"VALUES('"+ fristName + "','Ingredients')"; is insert value
all work good the Eclipse run it....

If I change the code like that:"INSERT INTO RECIPESTABLE(RECIPENAME,INGREDIENTS)"+"VALUES('Pizza ','Ingredients')"; is insert value pizza and I want when you Enter your name it insert your name
and i dont know how to change this code for that this will run.

Now when I run it the Output is:
Like this:

1 Any Recipe
2 frame0
3 frame0
4 frame0
5 frame0
6 null
7 frame0
8
9
10

and I try to write name like: Dan
and this not insert this.

you can try it in your computer and help me plss?I dont know what do to I have try everythings.


David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I'd recommend getting rid of access and trying to use a real database like MySQL with the Type 4 driver.

Failing that, I recommend doing this for your insert:
* get connection
* get statement for insert
* execute insert
* close statement
* get statement for select
* execute select, close ResultSet, close Statement
* close Connection

While you just throw out the results from the select, it is required to 'push' the insert statement through the Type-1 driver since due to a bug it can get stuck.
Another option is to setAutocommit(true) when you open a database Connection

Your code doesn't appear to close database resources when it is done with them, and this can also be the source of errors.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Need help with insert values into access
 
Similar Threads
Linux mysql and Jdbc
Vectors
java.lang.ClassCastException error
jframe not accepting sql query..
Too few parameters