【问题标题】:Spelling error in context.xml causes another error [closed]context.xml 中的拼写错误导致另一个错误[关闭]
【发布时间】:2013-06-21 19:51:59
【问题描述】:

我有一个在 META-INF/context.xml 中定义的数据库数据源的 Web 应用程序。

<Context>
    <Resource name="jdbc/MYJNDI"
              auth="Container"
              type="javax.sql.DataSource"
              username="Arash"
              password="who"
              driverClassNmae="oracle.jdbc.driver.OracleDriver"
              url="jdbc:oracle:thin:@localhost:1521:xe"
              maxActive="10"
              maxIdle="1"/>

</Context>

这是我的 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
          http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
         version="2.5">
    <resource-ref>
        <description>Oracel + jndi test</description>
        <res-ref-name>jdbc/MYJNDI</res-ref-name>
        <res-type>javax.sql.DataSource</res-type>
        <res-auth>Container</res-auth>
    </resource-ref>
</web-app>

问题是当我运行此代码时出现以下异常:

Context initContext = new InitialContext();
Context envContext = (Context) initContext.lookup("java:/comp/env");
DataSource ds = (DataSource) envContext.lookup("jdbc/MYJNDI");
**connection = ds.getConnection();**

例外: 无法为连接 URL 'jdbc:oracle:thin:@localhost:1521:xe' 创建类 '' 的 JDBC 驱动程序

【问题讨论】:

  • context.xml 有错误。 driverClassName 拼写错误。你复制粘贴了真实文件吗?
  • 是真的谢谢......
  • 你真的只是发布一个问题来帮助检查你的语法吗?

标签: java jdbc jndi connection-pooling


【解决方案1】:

context.xml 有错误。

driverClassName 拼写错误。

【讨论】:

    猜你喜欢
    • 2014-11-18
    • 1970-01-01
    • 1970-01-01
    • 2011-07-29
    • 2018-11-25
    • 1970-01-01
    • 1970-01-01
    • 2011-07-21
    • 2018-06-15
    相关资源
    最近更新 更多