Tomcat,Logon拒绝使用Oracle Database 11gR2

时间:2014-03-21 14:54:26

标签: java oracle tomcat jpa persistence.xml

我通过将TOMCAT部署的webapp连接到Oracle Database 11gR2来使用JPA。我收到以下错误。

javax.persistence.PersistenceException:Exception [EclipseLink-4002](Eclipse Persistence Services - 2.5.2.v20131113-a7346c6):org.eclipse.persistence.exceptions.DatabaseException 内部异常:java.sql.SQLException:ORA-01017:用户名/密码无效;登录被拒绝

我的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="tdoc" transaction-type="RESOURCE_LOCAL"> <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider> <class>mil.osd.dmdc.diss.tdoc.model.AbstractModelObject</class> <class>mil.osd.dmdc.diss.tdoc.model.GeneratedFile</class> <class>mil.osd.dmdc.diss.tdoc.model.Template</class> <class>mil.osd.dmdc.diss.tdoc.model.TemplateFile</class> <properties> <property name="eclipselink.jdbc.bind-parameters" value="false"/> <property name="javax.persistence.jdbc.driver" value="oracle.jdbc.OracleDriver"/> <property name="javax.persistence.jdbc.url" value="jdbc:oracle:thin:localhost:1521:tdoc"/> <property name="javax.persistence.jdbc.user" value="test"/> <property name="javax.persistence.jdbc.password" value="TEST"/>
<property name="eclipselink.target-server" value="None"/> <property name="eclipselink.logging.level.sql" value="FINE"/> <property name="eclipselink.logging.parameters" value="true"/> </properties>
</persistence-unit> </persistence>

我提供的凭据绝对正确,因为我可以使用它们连接到SQL Developer和SQL Plus。请帮忙!我已经被困在这几个小时了。

此外,我尝试关闭区分大小写,但它似乎也没有用。

修改的 我忘了提到我也在使用maven来构建项目,看起来这是为了防止我对eclipselinks的依赖是错误的

    `<project xmlns="http://maven.apache.org/POM/4.0.0"      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>testdata</groupId>
  <artifactId>testdata</artifactId>
  <version>1.0</version>
  <packaging>war</packaging>
  <name>testdata</name>
  <dependencies>
    <dependency>
      <groupId>org.eclipse.persistence</groupId>
      <artifactId>org.eclipse.persistence.jpa</artifactId>
      <version>2.5.2-M1</version>
    </dependency>
    <dependency>
      <groupId>com.oracle</groupId>
      <artifactId>ojdbc6</artifactId>
      <version>11.2.0</version>
    </dependency>
    <dependency>
      <groupId>org.apache.directory.studio</groupId>
      <artifactId>org.apache.commons.io</artifactId>
      <version>2.4</version>
    </dependency>
    <dependency>
        <groupId>org.glassfish</groupId>
        <artifactId>javax.faces</artifactId>
        <version>2.1.13</version>
    </dependency>
    <dependency>
      <groupId>javax.servlet</groupId>
      <artifactId>servlet-api</artifactId>
      <version>2.5</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.1</version>
        <configuration>
          <source>1.7</source>
          <target>1.7</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.3</version>
        <configuration>
          <warSourceDirectory>src/main/webapp</warSourceDirectory>
          <failOnMissingWebXml>true</failOnMissingWebXml>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>`

1 个答案:

答案 0 :(得分:1)

你的&#34; javax.persistence.jdbc.url&#34;财产对我来说有点奇怪。

尝试&#34; jdbc:oracle:thin:@localhost:1521:tdoc &#34;而不是&#34; jdbc:oracle:thin:localhost:1521:tdoc&#34; (见缺失的&#34; @&#34;?)