You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Chaohua Wang <cw...@incomm.com> on 2008/03/20 02:15:21 UTC

答复: how to load a bunch data from a txt file, and ant sql call these data

I am not interested in your link. I don't ask people for doing homework for me. 
I am asking for hint and some helpful links.  
Pleas  understand my question first. 


-----Original Message-----
From: Anderson, Rob (Global Trade) [mailto:Rob.Anderson@nike.com]
Sent: 2008-3-19 (星期三) 18:56
To: Ant Users List
Subject: RE: how to load a bunch data from a txt file, and ant sql call these data
 
I'm not trying to be a jerk, but you would probably benefit from reading
the following...

http://catb.org/~esr/faqs/smart-questions.html

I don't think anybody here is interested in doing your work for you. But
if you have specific questions about things you are having difficulty
with, we are happy to help if we can.

-Rob Anderson


-----Original Message-----
From: Chaohua Wang [mailto:cwang@incomm.com] 
Sent: Wednesday, March 19, 2008 3:52 PM
To: Ant Users List
Cc: floess@mindspring.com
Subject: how to load a bunch data from a txt file, and ant sql call
these data

Hi Folks,

I have a ant sql statement 


<target name="insertData">
		<sql driver="${jdbcdriver}" url="${dburl}/BillPay"
userid="${userid}" password="${password}"
			print="yes" onerror="continue"
output="${tmp.dir}/dbModification.txt">
			<transaction> INSERT INTO Payment (RefNumber,
VAN, Amount, OptCode, VendorID,
				PriorRefNumber, TransactionTS,
IsProcessed) VALUES
	
('6569998989','2131213','1131',2031,232,'7898', { fn NOW() },1);
</transaction>
			<transaction> INSERT INTO Payment (RefNumber,
VAN, Amount, OptCode, VendorID,
				PriorRefNumber, TransactionTS,
IsProcessed) VALUES
	
('9565689232323','21313213','1131',2031,232,'7898', { fn NOW() },1);
</transaction>
		</sql>

Here there are 2 sql statement to insert. But I have more than 100 data
put in txt file.

Like this
'1569998989','2131213','1131',2031,232,'7898', { fn NOW() },
'2569998989','2131213','1131',2031,232,'7898', { fn NOW() },
'3569998989','2131213','1131',2031,232,'7898', { fn NOW() },


Could you tell me How can load these data from a txt file. And using
loop to insert these data into database. Which means dynamically.
So I don't need to put  more thant 100 sql statement in the ant build
file. 

Thank you very much.

Cwang



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: 答复: how to load a bunch data from a txt file, and ant sql call these data

Posted by Kevin Jackson <fo...@gmail.com>.
Hi,

>  I have a ant sql statement
>
>
>  <target name="insertData">
>                 <sql driver="${jdbcdriver}" url="${dburl}/BillPay"
>  userid="${userid}" password="${password}"
>                         print="yes" onerror="continue"
>  output="${tmp.dir}/dbModification.txt">
>                         <transaction> INSERT INTO Payment (RefNumber,
>  VAN, Amount, OptCode, VendorID,
>                                 PriorRefNumber, TransactionTS,
>  IsProcessed) VALUES
>
>  ('6569998989','2131213','1131',2031,232,'7898', { fn NOW() },1);
>  </transaction>
>                         <transaction> INSERT INTO Payment (RefNumber,
>  VAN, Amount, OptCode, VendorID,
>                                 PriorRefNumber, TransactionTS,
>  IsProcessed) VALUES
>
>  ('9565689232323','21313213','1131',2031,232,'7898', { fn NOW() },1);
>  </transaction>
>                 </sql>
>
>  Here there are 2 sql statement to insert. But I have more than 100 data
>  put in txt file.
>
>  Like this
>  '1569998989','2131213','1131',2031,232,'7898', { fn NOW() },
>  '2569998989','2131213','1131',2031,232,'7898', { fn NOW() },
>  '3569998989','2131213','1131',2031,232,'7898', { fn NOW() },
>
>
>  Could you tell me How can load these data from a txt file. And using
>  loop to insert these data into database. Which means dynamically.
>  So I don't need to put  more thant 100 sql statement in the ant build
>  file.

Ant doesn't usually deal with 'loops' in the usual sense (imperative
programming style). In ant it's more normal to define a dataset and
perform the same operation for the entire set - not sure if I
explained that properly (morning coffee hasn't kicked in)

Here are a couple of suggestions:
- checkout dbunit it has good ant integration and makes this kind of
db interaction easy
- read the ant manual http://ant.apache.org/manual/CoreTasks/sql.html
<sql
    driver="org.database.jdbcDriver"
    url="jdbc:database-url"
    userid="sa"
    password="pass"
    src="data.sql"
/>

Please be aware that we are all busy, and this is not an uncommon
thing to want to do so there's a good chance that someone has an
example or has asked the question before.

In the future if you could try:
- Check the ant manual (see if there's a task that matches what you want to do)
- Read the mailing list archives (google search for them or try
http://marc.info/)
- Finally ask on the users list

You may feel that it was rude to ask you to read the standard 'How to
ask for help page', but really there's a good reason that page exists
and especially with open source software where everyone is a
volunteer.

Thanks,
Kev

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: how to load a bunch data from a txt file, and ant sql call these data

Posted by "Anderson, Rob (Global Trade)" <Ro...@nike.com>.
Good luck with that.

-Rob A

-----Original Message-----
From: Chaohua Wang [mailto:cwang@incomm.com] 
Sent: Wednesday, March 19, 2008 6:15 PM
To: Ant Users List; Ant Users List
Subject: ??: how to load a bunch data from a txt file, and ant sql call these data


I am not interested in your link. I don't ask people for doing homework for me. 
I am asking for hint and some helpful links.  
Pleas  understand my question first. 


-----Original Message-----
From: Anderson, Rob (Global Trade) [mailto:Rob.Anderson@nike.com]
Sent: 2008-3-19 (星期三) 18:56
To: Ant Users List
Subject: RE: how to load a bunch data from a txt file, and ant sql call these data
 
I'm not trying to be a jerk, but you would probably benefit from reading
the following...

http://catb.org/‾esr/faqs/smart-questions.html

I don't think anybody here is interested in doing your work for you. But
if you have specific questions about things you are having difficulty
with, we are happy to help if we can.

-Rob Anderson


-----Original Message-----
From: Chaohua Wang [mailto:cwang@incomm.com] 
Sent: Wednesday, March 19, 2008 3:52 PM
To: Ant Users List
Cc: floess@mindspring.com
Subject: how to load a bunch data from a txt file, and ant sql call
these data

Hi Folks,

I have a ant sql statement 


<target name="insertData">
		<sql driver="${jdbcdriver}" url="${dburl}/BillPay"
userid="${userid}" password="${password}"
			print="yes" onerror="continue"
output="${tmp.dir}/dbModification.txt">
			<transaction> INSERT INTO Payment (RefNumber,
VAN, Amount, OptCode, VendorID,
				PriorRefNumber, TransactionTS,
IsProcessed) VALUES
	
('6569998989','2131213','1131',2031,232,'7898', { fn NOW() },1);
</transaction>
			<transaction> INSERT INTO Payment (RefNumber,
VAN, Amount, OptCode, VendorID,
				PriorRefNumber, TransactionTS,
IsProcessed) VALUES
	
('9565689232323','21313213','1131',2031,232,'7898', { fn NOW() },1);
</transaction>
		</sql>

Here there are 2 sql statement to insert. But I have more than 100 data
put in txt file.

Like this
'1569998989','2131213','1131',2031,232,'7898', { fn NOW() },
'2569998989','2131213','1131',2031,232,'7898', { fn NOW() },
'3569998989','2131213','1131',2031,232,'7898', { fn NOW() },


Could you tell me How can load these data from a txt file. And using
loop to insert these data into database. Which means dynamically.
So I don't need to put  more thant 100 sql statement in the ant build
file. 

Thank you very much.

Cwang



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org