I am not completely new to Java, but I have recently learned about using a web.xml file to connect to a database.
It would be convenient to connect to the mySql I already have set, and a MSSql database within the same maven project.
I have researched this topic a bit, and haven't really found the answer I am looking for.
It isn't really helpful in terms of the question, but I have provided my web.xml as a code base if you would like to show me how this would be done.
Any help in the right direction would be appreciated.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
version="3.1">
<context-param>
<param-name>db.driver.class</param-name>
<param-value>com.mysql.jdbc.Driver</param-value>
</context-param>
<context-param>
<param-name>db.url</param-name>
<param-value>jdbc:mysql://localhost:3308/lib-1323</param-value>
</context-param>
<context-param>
<param-name>db.username</param-name>
<param-value>root</param-value>
</context-param>
<context-param>
<param-name>db.password</param-name>
<param-value>admin</param-value>
</context-param>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
</web-app>
This can be done. I would do some research on Spring and hibernate.
I found this article which may help .
You would need the Microsoft SQL Dependency in your pom.xml, and the correct driver.
Hope this helps.
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.