1 Replies - 2984 Views - Last Post: 23 September 2008 - 04:38 PM Rate Topic: -----

#1 nick2price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 562
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

JDBC multiple statements

Posted 23 September 2008 - 04:27 PM

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

Is This A Good Question/Topic? 0
  • +

Replies To: JDBC multiple statements

#2 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8329
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: JDBC multiple statements

Posted 23 September 2008 - 04:38 PM

View Postnick2price, on 23 Sep, 2008 - 04:27 PM, said:

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.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1