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.异常:
这是我配置的tomcat连接池,代码如下:
<Context path= "/bookstore " docBase= "bookstore "
debug= "5 " reloadable= "true " crossContext= "true ">
<Logger className= "org.apache.catalina.logger.FileLogger "
prefix= "localhost_DBTest_log. " suffix= ".txt "
timestamp= "true "/>
<Resource name= "jdbc/conmysql "
auth= "Container "
type= "javax.sql.DataSource "/>
<ResourceParams name= "jdbc/conmysql ">
<parameter>
<name> factory </name>
<value> org.apache.commons.dbcp.BasicDataSourceFactory </value>
</parameter>
<!-- Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.
-->
<parameter>
<name> maxActive </name>
<value> 100 </value>
</parameter>
<!-- Maximum number of idle dB connections to retain in pool.
Set to -1 for no limit. See also the DBCP documentation on this
and the minEvictableIdleTimeMillis configuration parameter.
-->
<parameter>
<name> maxIdle </name>
<value> 30 </value>
</parameter>
<!-- Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.
-->
<parameter>
<name> maxWait </name>
<value> 5000 </value>
</parameter>
<!-- MySQL dB username and password for dB connections -->
<parameter>
<name> username </name>
<value> root </value>
</parameter>
<parameter>
<name> password </name>