Every project will go through the database for a while. It was done before, because it was done on the basis of Tomcat, whether it was configured with ORCALE SQLSERVER2000 or MYSQL for a long time. however, I have never expected to use TOMCAT5.5 to do this. I am used to using TOMCAT5.5 only in proxool. xml is used in this configuration mode. however, I always believe that Tomcat 5.5 can be used in all modes. because the configuration is only one way.
I got a day yesterday and finally used the database to report the error "Cannot create JDBC driver of class'' for connect URL 'null. I thought that the configuration file must be wrong in the same way as before. I found that no half of the words were written wrong for a long time.
I checked on the Internet. I have met many of my brothers and I, but I have not succeeded in trying it out according to a brother.
We configured the database path in XXX. XML in TOMCAT_HOME \ conf \ Catalina \ localhost during the TOMCAT5.0 period.
<? Xml version = '1. 0' encoding = 'utf-8'?>
<Context docBase = "D: \ eclipse \ workspace \ BKGMS" path = "/BKGMS" reloadable = "true" workDir = "D: \ eclipse \ workspace \ BKGMS \ work \ org \ apache \ jsp ">
<Resource auth = "Container" name = "RedstoneSql" type = "javax. SQL. DataSource"/>
<ResourceParams name = "better">
<Parameter>
<Name> factory </name>
<Value> org. apache. commons. dbcp. basicperformancefactory </value>
</Parameter>
<Parameter>
<Name> url </name>
<Value> jdbc: microsoft: sqlserver: // 127.0.0.1: 1433; DatabaseName = bkgms </value>
</Parameter>
<Parameter>
<Name> password </name>
<Value> sa </value>
</Parameter>
<Parameter>
<Name> maxWait </name>
<Value> 10000 </value>
</Parameter>
<Parameter>
<Name> maxActive </name>
<Value> 100 </value>
</Parameter>
<Parameter>
<Name> driverClassName </name>
<Value> com. microsoft. jdbc. sqlserver. SQLServerDriver </value>
</Parameter>
<Parameter>
<Name> username </name>
<Value> sa </value>
</Parameter>
<Parameter>
<Name> maxIdle </name>
<Value> 30 </value>
</Parameter>
</ResourceParams>
</Context>
In <Resource auth = "Container" name = "better" type = "javax. SQL. <ResourceLink global = "better" name = "better" type = "javax. SQL. dataSource "/>.
However, after restarting TOMCAT, the following error occurs: unable to get connection: no suitable driver.
I rely on it, I think it is not spirit, and I will check it again. Most of the brothers have said that Tomcat 5.5 and tomcat 5.5.0 have different configurations.
After Tomcat5.5, the <Resoucepram> element of the <context> element is canceled. The original parameter elements all appear as the Resouce attribute.
But you should write it like this. By the way, add <ResourceLink>
<? Xml version = '1. 0' encoding = 'utf-8'?>
<Context docBase = "D: \ eclipse \ workspace \ BKGMS" path = "/BKGMS" reloadable = "true" workDir = "D: \ eclipse \ workspace \ BKGMS \ work \ org \ apache \ jsp ">
<Resource auth = "Container" name = "better" type = "javax. SQL. dataSource "maxWait =" 10000 "maxIdle =" 30 "maxActive =" 100 "username =" sa "password =" sa "driverClassName =" com. microsoft. jdbc. sqlserver. SQLServerDriver "url =" jdbc: microsoft: sqlserver: // 127.0.0.1: 1433; DatabaseName = bkgms "/>
<ResourceLink global = "better" name = "better" type = "javax. SQL. DataSource"/>
</Context>
1. path indicates the URL entry for accessing the web application;
2.doc Base specifies the file path of the web application, which can be an absolute path or a relative path relative to the appBase attribute of the Host;
3. type
4. maxActive is the maximum number of active database connections in DBCP. 0 indicates no restriction.
5. maxIdle is the maximum number of idle database connections in DBCP. The value 0 indicates no restriction.
6. maxWait is the maximum time (in milliseconds) for the database connection in DBCP to be idle. The value 0 indicates an indefinite wait.
7. username is the database Login Name
8. password is the database Login password
9. driverClassName is a database-only jdbc driver.
10. The url specifies the URL to connect to the database, and testDBCP is the name of my database.
Unable to get connection: no suitable driver
Started tomcat from eclipse and found org. apache. commons. dbcp. basicDataSourceFactory, so the factory = "org. apache. commons. dbcp. basicDataSourceFactory "is deleted, so the error is solved.
Of course, do not forget to add
<Resource-ref>
<Description> DB Connection </description>
<Res-ref-name> better </res-ref-name>
<Res-type> javax. SQL. DataSource </res-type>
<Res-auth> Container </res-auth>
</Resource-ref>
However, if you use SQLSERVER2000, make sure that the SP4 patch is installed.