简体   繁体   中英

Description of name=“jdbc/project” in Context.xml?

I need some help with the Context.xml file in my Java Web Application in Netbeans.

My task was to get my Web App to connect to and display products from my SQL database. I got it to work but I really need help understanding this code:

<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver"logAbandoned="true" maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/project" password="" removeAbandoned="true" removeAbandonedTimeout="60" type="javax.sql.DataSource" url="jdbc:mysql://localhost:3306/projinvoice?zeroDateTimeBehavior=convertToNull" username="root"/>

Could anyone tell me what name="jdbc/project" is? Where does this link to? If I change the name then the Web App does not display my products. How did it get set to jdbc/project and where can I find it?

I did try and use Glassfish to create a JDBC Resource where I could have used that name but it does not show up?

Any help would be appreciated. Regards

Context.xml is a configuration file for the container. Glassfish and Tomcat for example are using this file.

It declaratively configures the DataSource object in this case. At startup of the web-application, the container will instantiate this object and exposes it through JNDI.

JNDI is a mechanism to look for objects in the VM by name.

So somewhere on your web-app classes, this name is used to fetch this DataSource object. Have a search!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM