javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application resource file: java.naming.factory.initial
at javax.naming.spi.NamingManager.getInitialContext(Unknown Source)
at javax.naming.InitialContext.getDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.getURLOrDefaultInitCtx(Unknown Source)
at javax.naming.InitialContext.lookup(Unknown Source)
at com.connect.DBHelper.getConnection(DBHelper.java:15)
at com.connect.DemoConnect.main(DemoConnect.java:13)
java.lang.NullPointerException
有什么例外?我正在尝试使用数据源..这是我的 context.xml 文件..我在 meta-inf 文件夹中添加了 xml 文件,并在 tomcat lib 文件夹中添加了 ojdbc14.jar..
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Resource name="jdbc/mydatasource"
auth="Container"
type="javax.sql.DataSource"
username="YOUR_USERNAME"
password="YOUR_PASSWORD"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:[oracletrg/oracle]@10.180.168.112[:1521]/orcl?autoReconnect=true"
maxActive="10"
maxIdle="4"/>
</Context>