You may be able to do it in maven.xml with jelly scripting.
But I guess it woulde be a lot easier to develop your own plugin.

I havan't had to develop one myself so far so I cannot really give you
advices on how to do it.

You should use the JDBC driver provided by the PostgeSQL team for the
specific version of the database you have installed.


On 12/7/05, charles Anto <[EMAIL PROTECTED]> wrote:
>
> Many thanx daniel.
> How can i integrate these code with maven scripts. which driver i shd
> use postgresql or jdbc...?
> should i declear following code in the project.properties file?
> java.lang.Class.forName("org.postgresql.Driver");
>        java.sql.Connection jdbcConnection = DriverManager.getConnection
> ("jdbc:postgresql://localhost:5432/database", "postgres", "postgres");
>        DatabaseConnection databaseConnection = new
> DatabaseConnection(jdbcConnection, "public");
>
>
> Thanks & Regards
> Charles
>
> On 12/7/05, Daniel Beland <[EMAIL PROTECTED]> wrote:
> >
> > Hi,
> >
> >
> > It is quite easy to backup a database using DBUnit in java. So I gues
> you
> > would have to create a plugin to best achieve it.
> >
> > But the steps you will need to execute are:
> >
> > create a new DatabaseConnection object. (note the use of the public
> schema
> > for postgresql when the tables are not in a specific schema)
> >
> > Something like:
> >        java.lang.Class.forName("org.postgresql.Driver");
> >        java.sql.Connection jdbcConnection = DriverManager.getConnection
> > ("jdbc:postgresql://localhost:5432/database", "postgres", "postgres");
> >        DatabaseConnection databaseConnection = new
> > DatabaseConnection(jdbcConnection, "public");
> >
> >
> > Create the dataSet of the data to backup (can use complex queries to
> > filter
> > data) and write it in a file. The XmlDataSet format is hard to read
> > compared
> > to FlatXmlDataSet but is better to handle null values.
> >
> >        QueryDataSet dataSet = new QueryDataSet(databaseConnection);
> >        dataSet.addTable("table1");
> >        dataSet.addTable("table2");
> >        dataSet.addTable("table3", "select * from table3 where xxx >
> > 5000");
> >
> >        XmlDataSet.write(dataSet, new
> > FileOutputStream("C:/tmp/dataSet.xml"));
> >
> >
> > Then re-import the data when it is done
> >
> >        XmlDataSet dataSet2 = new XmlDataSet(new
> > FileInputStream("C:/tmp/dataSet.xml"));
> >        DatabaseOperation.CLEAN_INSERT.execute(databaseConnection,
> > dataSet2);
> >
> >
> > Hope it can help
> >
> > Daniel
> >
> >
> >
> > On 12/7/05, Charles A <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > >         Hi All,
> > >
> > >           I'm using Hibernate and Postgresql DB in our project. Now my
> > > maven script creating .War file.
> > >         But problem is i have to take back-up and delete my database
> > > before run the maven script and restore the back-up database, once new
> > > database has created.
> > >         I have checked DBUNIT and ddlutils site, but i didn't get
> clear
> > > idea where to start? and  how to proceed?
> > >
> > >         Thanks in advance
> > >
> > >         Thanks & Regards
> > >         Charles
> > >
> > >
> > >
> >
> >
>
>

Reply via email to