How to Define a MySql datasource bean via XML in Spring

前端 未结 3 1005
不思量自难忘°
不思量自难忘° 2020-12-09 05:09

I\'ve looked over the documentation to define a bean. I\'m just unclear on what class file to use for a Mysql database. Can anyone fill in the bean definition below?

3条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-09 05:34

    Both the answers are appropriate for the question. But just for an FYI if you're going to use DriverManagerDataSource as your datasource, every call to your datasource bean will create a new connection to your database which is not recommended for production and even it does not pool connections.

    If you need a connection pool, consider Apache Commons DBCP.

    
        
        
        
        
        
        
    
    

    Where initialSize and maxActive are pooling related properties.

    To use this make sure you have the required jar in your path.

提交回复
热议问题