Source Code : Generate Hibernate Config File: Set Your Own Driver Class

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Generate Hibernate Config File: Set Your Own Driver Class

/////////////////////////////////////////////////////////////////////////

<project name="hibernate-tutorial" default="compile">

    <property name="sourcedir" value="${basedir}/src"/>
    <property name="targetdir" value="${basedir}/build"/>
    <property name="librarydir" value="${basedir}/lib"/>

    <path id="libraries">
        <fileset dir="${librarydir}">
            <include name="*.jar"/>
        </fileset>
    </path>

    <target name="clean">
        <delete dir="${targetdir}"/>
        <mkdir dir="${targetdir}"/>
    </target>

    <target name="compile" depends="clean, copy-resources">
      <javac srcdir="${sourcedir}"
             destdir="${targetdir}"
             classpathref="libraries"
             debug="on"/>
    </target>

    <target name="copy-resources">
        <copy todir="${targetdir}">
            <fileset dir="${sourcedir}">
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>

    <target name="driver">
        <property name="hibernate.connection.driver_class" value="yourDriverClass"/>
        <antcall target="hbm"/>
    </target>


    <target name="hbm" depends="compile">
        <taskdef
            name="hibernatedoclet"
            classname="xdoclet.modules.hibernate.HibernateDocletTask"
            classpathref="libraries"
            />
        <hibernatedoclet
            destdir="${targetdir}"
            verbose="true">
            <fileset dir="${sourcedir}">
                <include name="**/*.java"/>
            </fileset>
            <hibernate version="3.0"/>
            <hibernatecfg
                dialect="${hibernate.dialect}"
                jdbcUrl="${hibernate.connection.url}"
                driver="${hibernate.connection.driver_class}"
                userName="${hibernate.connection.username}"
                password="${hibernate.connection.password}"
                showSql="false"
                version="3.0"
                />
        </hibernatedoclet>
    </target>

</project>


           
       

Thank with us