2016-07-02 49 views
0

我需要使用JPA實現的jboss-AS-7.1.1(休眠),但在部署應用程序時,服務器應用程序顯示了這個消息:爲什麼不能jboss找到適合此網址的驅動程序?

Could not obtain connection to query metadata : No suitable driver found for jdbc:oracle:thin:@localhost:1521:xe 

我加入ojdbc6罐子作爲一個全球性的模塊。事實上,服務器表明它是能夠找到驅動程序類的類路徑:

using driver [oracle.jdbc.OracleDriver] at URL [jdbc:oracle:thin:@localhost:1521:xe] 

這是我的persistence.xml以防萬一:

<?xml version="1.0" encoding="UTF-8"?> 
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"> 
    <persistence-unit name="HBOService"> 
     <exclude-unlisted-classes>false</exclude-unlisted-classes> 
     <properties> 
      <property name="hibernate.dialect" value="org.hibernate.dialect.Oracle10gDialect"/> 
      <property name="hibernate.connection.driver_class" value="oracle.jdbc.OracleDriver"/> 
      <property name="hibernate.connection.url" value="jdbc:oracle:thin:@localhost:1521:xe"/> 
      <property name="hibernate.connection.username" value="HBOWEB"/> 
      <property name="hibernate.connection.password" value="****"/> 
     </properties> 
    </persistence-unit> 
</persistence> 

更多信息:

通過我使用這個完全相同的參數的方式,創建了一個數據源,更新了我的persistence.xml以使用這個數據源並且它完美地工作。

那麼,這是怎麼回事? jboss 7是否支持非數據源連接?可能是什麼問題呢?

回答

0

JBoss的7不與數據庫驅動程序船舶等收錄的Oracle或MySQL等

您需要創建一個JBoss模塊對他們來說並把它添加到你的JBoss 7的安裝。請參閱jboss 7 oracle datasource configuration的答案

然後,您需要從WAR應用程序向Oracle數據庫模塊添加依賴項。這可以使用jboss-dependency.xml文件或MANIFEST.MF文件完成。詳情請見Best Practice for loading 3rd party JARs in JBoss AS7 standalone deployment?

+0

我做到了。你可以看到我在問題中添加了ojdbc6.jar。 –

相關問題