Why I can't save data in data base?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: Why I can't save data in data base?

  1. #1
    Join Date
    Oct 2006
    Location
    Kaniv, Ukraine
    Posts
    4

    Why I can't save data in data base?

    My web-application consist of servlet and applet. Applet view some table from data base and user can edit and save her. Exactly, applet send query to servlet for getting data from data base. I use DataExpress components.

    Getting data from data base. Applet send to the servlet data base's name, table's name, data base's URL, driver's name, login and password. Servlet use this data for making query, send him to the data base and return data to the applet. It's I done and this is working.

    Saving data in data base
    . When user clicked "Save" button, applet send servlet object NewMetaDataDBConnection. NewMetaDataDBConnection has base's name, table's name, data base's URL, driver's name, login, password and, of course, data. I promise that this object has right data, but next code doesn't save in data base

    Code:
    database1.setConnection(new ConnectionDescriptor(NewMetaDataDBConnection.URL, NewMetaDataDBConnection.Login, NewMetaDataDBConnection.Password, false,NewMetaDataDBConnection.Driver));
            database1.setDatabaseName("");
    
              NewMetaDataDBConnection.data.loadDataSet(queryDataSet1);
              DataSetData data = DataSetData.extractDataSet( queryDataSet1 );
              database1.saveChanges(queryDataSet1);
    Attached Files Attached Files

  2. #2
    Join Date
    Sep 2006
    Posts
    68
    Hi!
    Did you try to flush(commit) your data after database1.saveChanges(queryDataSet1)?

  3. #3
    Join Date
    Oct 2006
    Location
    Kaniv, Ukraine
    Posts
    4
    Uladzimir

    No, I didn't try. It's good idea... I try this tomorrow and say later.

  4. #4
    Join Date
    Oct 2006
    Location
    Kaniv, Ukraine
    Posts
    4
    I wrote:
    Code:
    database1.setConnection(new ConnectionDescriptor(NewMetaDataDBConnection.URL, NewMetaDataDBConnection.Login, NewMetaDataDBConnection.Password, false,NewMetaDataDBConnection.Driver));
            database1.setDatabaseName("");
    NewMetaDataDBConnection.data.loadDataSet(queryDataSet1);
              database1.saveChanges(queryDataSet1);
            
           database1.commit();
    And I tried write database1.rollback(); instead of database1.commit(); but it's doesn't save data too... :-(

  5. #5
    Join Date
    Sep 2006
    Posts
    68
    If transactions are disabled, you must call database.getJDBCConnection().connection.commit().

  6. #6
    Join Date
    Oct 2006
    Location
    Kaniv, Ukraine
    Posts
    4
    I wrote database1.getJdbcConnection().rollback();/ database1.getJdbcConnection().commit();. And nothing. :-(. Maybe, I do something wrong but I don't understand what...

  7. #7
    Join Date
    Sep 2006
    Posts
    68
    Hmm...
    I took a look at your code... Do not be resentful but sometime it very terrible. Never write an empty catch block. If exception occurs how do you understand that?

    So try to debug carefully:
    1. Do you create a valid SQL query.
    2. Does it insert a non empty result into a DB.
    3. Does the insert operation committed and flushed.

    If all OK then the problem happens not with the DB operation but somewhere else.

  8. #8
    Join Date
    Oct 2006
    Posts
    5
    Improve your Exception Handling, thats the thing you should try out first!

Similar Threads

  1. Replies: 7
    Last Post: 03-07-2006, 05:34 PM
  2. Replies: 0
    Last Post: 01-04-2006, 01:24 PM
  3. Registry question: Save and read binary data
    By Paulo Costa in forum VB Classic
    Replies: 0
    Last Post: 07-30-2001, 06:15 PM
  4. Access Data Base Security
    By Irfan in forum VB Classic
    Replies: 3
    Last Post: 11-27-2000, 10:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center