How should I connect to JDBC database / datasource in a servlet based application?

前端 未结 2 802
小蘑菇
小蘑菇 2020-11-22 06:38

I have an external MySQL server that\'s set up and working fine. I created a database connection in Eclipse and can view the database in the Data Source Explorer tab.

2条回答
  •  深忆病人
    2020-11-22 07:35

    You could set up a data source in whatever app server you're deploying your WAR to and fetch a reference to it with JNDI. Or you could package your WAR in an EAR and define the data source in the EAR's data-sources.xml file (and fetch a reference to it with JNDI).

提交回复
热议问题