I have a java swing application and have mysql database.

I used hybernet for database connection. when i build this project with netbeans it create a jar file inside dist fodler. i want to edit my connection string after jar file creation. because client should be edit this database username,password and source.

I wrote this following code on build.xml file to write hibernet.cfg.xml file to dist folder. but application cannot read this file at run time.

<target name="-pre-compile">

<copy file="src/hibernate.cfg.xml" todir="dist/conf" >


this is my code for session factory. but it cannot read dist folder. it reads build folder.

URL resource = getClass().getClassLoader().getResource("/dist/conf/hibernate.cfg.xml");
//URL resource = ClassLoader.getSystemResource("conf/hibernate.cfg.xml");
factory = new Configuration().configure().buildSessionFactory();
}catch (Throwable ex) {
System.err.println("Failed to create sessionFactory object." + ex);
throw new ExceptionInInitializerError(ex);

please help me.