File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Insert statement Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Insert statement" Watch "Insert statement" New topic

Insert statement

Abdul Sameer

Joined: Oct 11, 2000
Posts: 3
I am using MS-Access as back end for an application that I am developing using java.I have a HTML form which consists of two input boxes.I want to take the values typed in input boxes and add them to the table.I tried using Insert statement but it is not working.I think there is some problem with the code.Though the insert statement is working in MS-Access query but it is not working when I am trying to insert values into the table from the java code.Can anyone please help me?
Pranav Jaidka
Ranch Hand

Joined: Sep 14, 2000
Posts: 264
hi abdul
your query doesnt explain where in your code you are actually going wrong .......
anyway try doing all of the following
1> Register a driver using the Class.forName("driver") statement this drive should be compatible for use with the database you are using;
2> Create a connection to the database using DriverManager.getConnection();
Create an sql statements using the Connection.CreateStatement() method
4> use the executeUpdate() method on the statement to fire the insert statement......
this should work
Rajesh Hegde
Ranch Hand

Joined: Sep 15, 2000
Posts: 112
what is the error or exception u are getting u are getting. Also please post the code that is doing the job of insertion.
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
i got the same error too. i have got perfect connection with msaccess and my java code queries well, infact it do all the reading stuff from the database very well. the problem arise only when i try to write somethign to the database, either thru INSERT or CREATE, the error msg it gives is
suitable driver not found
n then it dont connect to the database, but its compiled without any errors. only give runtime errors. someone suggested to me not to use msaccess for these kinda purposes. so i am gonna try SQL SERVER and advise u to do the same too , adios
Abdul Sameer

Joined: Oct 11, 2000
Posts: 3
Hi Rajesh,
My code is neither showing any error nor throwing any exceptions.Here is the code.

Please help me.Also Im using servlets.
Added UBB CODE tags to preserve indentation
[This message has been edited by Frank Carver (edited October 25, 2000).]
Monty Ireland
Ranch Hand

Joined: Oct 03, 2000
Posts: 161
Check you JDBC driver doc...
You are using a JDBC ver 2.0 feature...
Make sure you driver is JDBC ver 2.0 compatiable...
Hope this helps...

We learn more from our mistake's than from our success's.
a.k.a. monty6

Multi Platform Database Developer & DBA on E.S.T.

Joined: Nov 28, 2002
Posts: 1
try before all use of row
I agree. Here's the link:
subject: Insert statement
It's not a secret anymore!