Refresh Your Java - Before Java Interview
We are Agile, believe in less Documentation - Only Quick notes (Java Interview Questions) of Java/J2ee Read more....
Step 1:
Hibernate Classes also
should be tested as normal classes, with exception of passing
the
hibernate Properties files as follows.
System.setProperty("hibernate.properties.file.name", "hibernate_junit.properties");
Step
2:
In Hiberante Properties file or XML file
you need to use dbcp
Connection API as follows.
hibernate.dialect org.hibernate.dialect.OracleDialect
hibernate.connection.driver_class
oracle.jdbc.driver.OracleDriver
hibernate.connection.url
jdbc:oracle:thin:@HostName:1522:DBName
hibernate.connection.username sa
hibernate.connection.password yourPassword
hibernate.connection.pool_size 5
hibernate.dbcp.poolPreparedStatements
true
#hibernate.dbcp.ps.maxActive
hibernate.connection.provider_class
com.salesorder.DBCPConnectionProvider
Step 3 :
Create Your own DBCPConnectionProvider as follows
public class DBCPConnectionProvider implements ConnectionProvider {
private
static final Log log =
LogFactory.getLog(DBCPConnectionProvider.class);
private static final String PREFIX
= "hibernate.dbcp.";
private BasicDataSource ds;
}
Step 4:
Write a TestCase as
follows
public class SalesOrderTestCase extends TestCase {
static
{
try {
System.setProperty("hibernate.properties.file.name",
"hibernateDEV_junit.properties");
new HibernateConfig().init(null);
}
catch (Exception ex) {
System.err.println("Could not initialize Hibernate
Config");
throw new RuntimeException("Could not initialize
Hibernate Config");
}
}
public SalesOrderTestCase() {
super("SalesOrderTestCase");
}
public SalesOrderTestCase(String
name) {
super(name);
}
/**
* override this in a
subclass if you want to setup a separate principle than
* nkuppili.
*/
public void setUp() throws
Exception {
super.setUp();
}
public void
tearDown() throws Exception {
HibernateConfig.closeSession();
}
}
This Portal is intended to put all Java/J2ee related topics at one single place for quick referance, not only Technical , but also the Project Management Related thing such as Development Process methodoogies build process, unit testing etc.,
This Portal has More than 500 Java Interview Questions (also could be Considered as Quick Notes) very neatly separated topic by topic with simple diagrams which makes you easily understandable. Importantly these are from our Realtime expericance.