Results 1 to 5 of 5
  1. #1
    jperson is offline Member
    Join Date
    Jan 2010
    Posts
    61
    Rep Power
    0

    Default insert vector to database

    Java Code:
            try {
                record.displayTable(getCols());
    // get inserted record 
                Vector newRecord = record.getNewRecord(); 
                if (newRecord == null) {
                    return;
                }
    //add new record to JTable 
                tableModel.addRow(newRecord);
    
    
    // how to add newRecord "Vector" to database

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,861
    Rep Power
    19

    Default

    What is the Vector?
    Is it supposed to represent the record to insert?

  3. #3
    jperson is offline Member
    Join Date
    Jan 2010
    Posts
    61
    Rep Power
    0

    Default

    it's the data type of newRecord, yes i want to insert this record

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,861
    Rep Power
    19

    Default

    So different parts of this Vector represent different columns in the database?
    If so then this should be a class of some sort really, and not a Vector.

    Anyway, that aside, presumably you know JDBC...in which case what code do you have for inserting at the moment? What have you tried?

  5. #5
    Dinesh_rockz is offline Member
    Join Date
    Jan 2011
    Location
    India
    Posts
    22
    Rep Power
    0

    Default

    ListIterator used to traverse the vector

    Java Code:
    ListIterator  lt =newRecord.listIterator();
    
    
    			while (lt.hasNext()) 
    
    				{
         //You can get vector row values to string by using lt.next().toString();
    // Your Insert Code here
                        
    		          }

Similar Threads

  1. how to insert data in database
    By Vinay Bhatia in forum JDBC
    Replies: 6
    Last Post: 11-03-2010, 04:06 PM
  2. why i can't insert data to database
    By khaa_khay in forum Web Frameworks
    Replies: 0
    Last Post: 05-26-2010, 05:37 AM
  3. how to insert sql file into database using swing
    By ravi.virgoo@gmail.com in forum AWT / Swing
    Replies: 1
    Last Post: 11-22-2009, 03:01 AM
  4. Replies: 3
    Last Post: 02-28-2009, 09:17 AM
  5. Replies: 0
    Last Post: 02-10-2008, 11:25 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
  •