ANT control Oracle database practice
By Guipei
2005-3-21
Recently, development work is relatively busy, often take the project home overtime, project use Oracle database, because the machine can not start the Oracle related service as automatic start, this, what is estimated that my girlfriend will say how to get your computer, It is so difficult to open a machine. So, every time you start writing a program, always open the console, NET Start a lot, open the database, open the monitor, always, one day hate this repetitive labor, hand it over to Ant.
Ant execution system commands There is no problem. In this actual system command, two problems can be said, one is the command to start the service is spaced, the second how to back up the database can be automatically added.
First, we launched an Oracle database and operate two:
1. Start monitoring:
exec>
2. Open the database instance:
exec>
The first operation is nothing distinguish here, that is, the standard usage of the ANT call system command, let's take a look at the second command, net start oracleservice $ {ora_sid}, if you put it directly into the executable property, the execution result will be Yes:
Build failed: E: /JAVA/testant/build.xml: 44: execute failed: java.io.IOException: CreateProcess: "Net Start OracleserviceMy_Ot Start ORACleServiceMy_Ot Start OraclesError = 2
Pain, command with spaces should use the following methods:
exec>
If you add a time tag when you back up the database, I use the tit book backup Oracle database under Linux, you can use the data command to make it easy to add a date suffix on the backup file, Ant is?
I checked a lot of information, I finally got it:
tstamp>
Using TSTAMP TARGET can be very convenient to define the date property so that you can make your questions for your questions.
OK, you can refer to the completed Ant script:
Appendix: Reference script