Welcome to Dream.In.Code
Become a Java Expert!

Join 150,197 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,037 people online right now. Registration is fast and FREE... Join Now!




JDBC multiple statements

 
Reply to this topicStart new topic

JDBC multiple statements

nick2price
23 Sep, 2008 - 03:27 PM
Post #1

D.I.C Regular
***

Joined: 23 Nov, 2007
Posts: 338



Thanked: 12 times
My Contributions
Right, i need to be put on suicide watch after spending two days solid on this, so i have decided to take another approach. So i am going back to the INSERT INTO part of my code but i wanna make a slight change,
heres the original statement
CODE
        try
        {
            con = DatabaseUtils.connect(DRIVER, URL);  
            String sql = "INSERT INTO Competitor(Competitor_ID, First_Name, Last_Name, Time_Set) VALUES (?, ?, ?, ?)";
            ps = con.prepareStatement(sql);
               
               for(int i = 0; i < update1.length; i++)
            {
            ps.setString(1, update2[i].getidNo());
            ps.setString(2, update2[i].getFirstname());
            ps.setString(3, update2[i].getLastname());
            ps.setString(4, update2[i].getTime());
            ps.addBatch();
            }
            
            
            int[] upCounts = ps.executeBatch(  );
            con.commit(  );

        }


Now the object i am looping has four variables going to the same table. I would like to remove the fourth one, Time_Set, and send it to a different table called RoundCompetitor. Is this possible or would i need to create a new Object which only has the first three variables?
cheers
User is offlineProfile CardPM
+Quote Post

pbl
RE: JDBC Multiple Statements
23 Sep, 2008 - 03:38 PM
Post #2

D.I.C Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 3,587



Thanked: 233 times
Dream Kudos: 75
My Contributions
QUOTE(nick2price @ 23 Sep, 2008 - 04:27 PM) *

Now the object i am looping has four variables going to the same table. I would like to remove the fourth one, Time_Set, and send it to a different table called RoundCompetitor. Is this possible or would i need to create a new Object which only has the first three variables?
cheers

You are not putting the object in the database you are putting Strings that you remove from this object so who cares if the object has an extra instance variable.
even if you where the object by itself in the database, the database does care if the instance variables of this object are in a column or not.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 04:44AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month