我搜索并尝试了很多,但没有任何帮助。
我得到了#34;众所周知的#34; -错误。 (错误代码:0 - 没有更多信息)
我的持久性-.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd">
<persistence-unit name="JPA_PU" transaction-type="RESOURCE_LOCAL">
<non-jta-data-source>java:/comp/env/jdbc/jpaConnector</non-jta-data-source>
<!-- <properties> -->
<!-- <property name="eclipselink.target-database" value="SQLServer" /> -->
<!-- <property name="javax.persistence.jdbc.driver" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" /> -->
<!-- <property name="javax.persistence.jdbc.url" value="jdbc:sqlserver://sqlserver01:1433;databaseName=DB_NAME" /> -->
<!-- <property name="javax.persistence.jdbc.user" value="jpaUsr" /> -->
<!-- <property name="javax.persistence.jdbc.password" value="pwd01" /> -->
<!-- </properties> -->
</persistence-unit>
</persistence>
我的web.xml
...
</servlet-mapping>
<resource-ref>
<res-ref-name>jdbc/jpaConnector</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
...
</web-app>
我的server.xml(Catalina_home \ conf \ server.xml)
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase" description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory" pathname="conf/tomcat-users.xml" />
<Resource name="jdbc/jpaConnector" auth="Container"
type="javax.sql.DataSource" username="jpaUsr"
password="pwd01" driverClassName="com.microsoft.sqlserver.jdbc.SQLServerDriver"
url="jdbc:sqlserver://sqlserver01:1433;databaseName=DB_NAME"
maxActive="8" maxIdle="4"/>
</GlobalNamingResources>
我尝试过的事情:
- 使用直接访问数据库的方式(persistence.xml中的注释)...是的,它的工作原理!所以我认为司机和一切都在运作。
版本:
Tomcat 7.0.47
Eclipse-Link 2.5.2
SQL Server 2014 Express JDBC驱动程序:4.0.2206.100