|
-
Sep 18th, 2007, 03:28 AM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Jdbc Insert Query Issue
Hi
I have defined driver, connection,url , statement. All working fine. Even for SELECT statement I am being shown the records present in my DB table.
The problem is that when I am Inserting records and running the program it is showing no error or Exception but the records are not inserted (the application runs succesfully), What should I do?
I am using executeUpdate("INSERT INTO TABLENAME VALUES([I]VALUE1,VALUE2,VALUE3,.......VALUEn/I]n"));
And I am using MS-Access DB I have not to define the USER and PASSWORD Parameter. And also I have checked that the DB file is not readonly.
If a locking mechanism is implemented how to unlock it?
Thanks in Advance
-
Sep 18th, 2007, 11:22 AM
#2
Re: Jdbc Insert Query Issue
This is not how you write Access insert query
it should be something like:
Code:
INSERT INTO TableName ( Field1, Field2, ... )
SELECT [String] AS Expr1, 11/11/2004 AS Expr2;
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
-
Sep 18th, 2007, 01:54 PM
#3
Thread Starter
Hyperactive Member
Re: Jdbc Insert Query Issue
 Originally Posted by ComputerJy
This is not how you write Access insert query
it should be something like:
Code:
INSERT INTO TableName ( Field1, Field2, ... )
SELECT [String] AS Expr1, 11/11/2004 AS Expr2;
I wrote my mentioned query in MS-Access itself and it is working fine.
Well I think there is some other problem.
-
Sep 24th, 2007, 01:12 AM
#4
Thread Starter
Hyperactive Member
Re: Jdbc Insert Query Issue
I did it myself but I dont why it is happening. When using executeUpdate("DML") you dont need to store it in a resultset. Howver when defining select queries you must have to store it in a resultset,
I have done this
Statement st=connectionname.createStatement();
then
st.executeUpdate("My insert query");
Resultset rs=st.executeQuery("Give simple SELECT QUERY");
-
Sep 24th, 2007, 08:00 AM
#5
Re: [RESOLVED] Jdbc Insert Query Issue
because an update statement is non query therefore it returns an int (row count)
on the other hand a select statement returns a tabular form of data
"I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
My Blog
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|