Results 1 to 5 of 5

Thread: [RESOLVED] Jdbc Insert Query Issue

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    275

    Resolved [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

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    275

    Re: Jdbc Insert Query Issue

    Quote 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.

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Feb 2006
    Posts
    275

    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");

  5. #5
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    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
  •  



Click Here to Expand Forum to Full Width