[jboss-user] [EJB 3.0] - Driver problems with Persistence.XML
breako
do-not-reply at jboss.com
Tue Nov 20 11:51:04 EST 2007
Hi,
I have a very simple War, which contains a JSP and a pesistence.xml file.
The Persistence.XML defines my persistence unit:
| <persistence-unit name="h-source">
| <properties>
| <property name="hibernate.connection.driver_class" value="oracle.jdbc.driver.OracleDriver"/>
| <property name="hibernate.connection.username" value="test_garageDB"/>
| <property name="hibernate.connection.password" value="test_garageDB"/>
| <property name="hibernate.connection.url" value="jdbc:oracle:thin:@opc151:1521:ora10g"/>
| <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
| <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle9Dialect"/>
| </properties>
| </persistence-unit>
|
|
The JSP creates and excutes a simple query
| <%@ page info="Test" language="java"
| import="javax.transaction.*, javax.naming.*, java.sql.*, com.arjuna.ats.jdbc.TransactionalDriver, java.util.Properties,
| oracle.jdbc.xa.client.OracleXADataSource, javax.sql.*, javax.persistence.*,
| org.hibernate.ejb.EntityManagerImpl"%>
| <html>
| <body>
| Home is HOME
| <%
| oracle.jdbc.driver.OracleDriver d = new oracle.jdbc.driver.OracleDriver();
| DriverManager.registerDriver(d);
|
|
| EntityManagerFactory emf =
| Persistence.createEntityManagerFactory("h-source");
| System.out.println("emf is " + emf);
| EntityManager em = emf.createEntityManager();
| EntityManagerImpl emImpl = (EntityManagerImpl)em;
| Connection con = emImpl.getSession().connection();
| System.out.println("Connection is " + con);
| System.out.println("em is " + em);
| Query q = em.createNativeQuery("insert into TAddress (C, I, CITY) " +
| "VALUES (" + 29 + ", " + 333 +
| ", 'DUBLIN7')");
| q.getSingleResult();
| %>
|
| </body>
| </html>
|
However, I get:
| java.sql.SQLException: No suitable driver
| java.sql.DriverManager.getConnection(DriverManager.java:545)
| java.sql.DriverManager.getConnection(DriverManager.java:140)
|
I have my driver jar in the lib directory.
I also instantiate it, so I cannot see what I am doing wrong?
Any ideas
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4106475#4106475
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4106475
More information about the jboss-user
mailing list