I'm having trouble making a webapp work. i am using Red Hat JBoss Developer Studio 8.1.0.GA and i encountered an error when deploying.
java.sql.SQLException: No suitable driver found for jdbc:postgresql://localhost:5432/hibernatedb
here is my persistence.xml
<persistence-unit name="HibernateProject"
transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<class>com.test.model.UserDetails</class>
<properties>
<property name="hibernate.connection.driver.class" value="org.postgresql.Driver"></property>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="validate" />
<property name="hibernate.connection.url"
value="jdbc:postgresql://localhost:5432/hibernatedb"></property>
<property name="hibernate.connection.username" value="postgres"></property>
<property name="hibernate.connection.password" value="1234"></property>
</properties>
</persistence-unit>
here is my servlet
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
UserDetails user = new UserDetails();
user.setUserName(request.getParameter("username"));
//use persistence-unit name from persistence.xml
EntityManagerFactory entityFactory = Persistence.createEntityManagerFactory("HibernateProject");
EntityManager entityManager = entityFactory.createEntityManager();
EntityTransaction entityTransaction = null;
try{
entityTransaction = entityManager.getTransaction();
entityTransaction.begin();
entityManager.persist(user);
entityTransaction.commit();
}catch(RuntimeException re){
if(entityTransaction.isActive()){
entityTransaction.rollback();
throw re;
}
}
}
Thanks alot!