|
@@ -1,16 +1,34 @@
|
1
|
1
|
package com.service.impl;
|
2
|
2
|
|
3
|
3
|
import com.dao.UserDao;
|
|
4
|
+import com.mchange.v2.c3p0.ComboPooledDataSource;
|
4
|
5
|
import com.service.UserService;
|
5
|
6
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
7
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
6
|
8
|
import org.springframework.stereotype.Service;
|
7
|
9
|
|
|
10
|
+import java.beans.PropertyVetoException;
|
|
11
|
+
|
8
|
12
|
@Service
|
9
|
13
|
public class UserServiceImpl implements UserService {
|
10
|
14
|
@Autowired
|
11
|
15
|
private UserDao userDao;
|
|
16
|
+ private JdbcTemplate jdbcTemplate;
|
12
|
17
|
@Override
|
13
|
18
|
public void saveUser() {
|
|
19
|
+ jdbcTemplate = new JdbcTemplate();
|
|
20
|
+ ComboPooledDataSource comboPooledDataSource = new ComboPooledDataSource();
|
|
21
|
+ try {
|
|
22
|
+ comboPooledDataSource.setDriverClass("com.mysql.cj.jdbc.Driver");
|
|
23
|
+ comboPooledDataSource.setJdbcUrl("jdbc:mysql://47.110.156.18:3306/sczn_eshop_test?zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai");
|
|
24
|
+ comboPooledDataSource.setUser("sczn");
|
|
25
|
+ comboPooledDataSource.setPassword("sczn159357");
|
|
26
|
+ this.jdbcTemplate.setDataSource(comboPooledDataSource);
|
|
27
|
+ int row = this.jdbcTemplate.update("insert into `wb_tbl_a`(company_id,status) " +
|
|
28
|
+ "values (?,?)", 100, 100);
|
|
29
|
+ } catch (Exception e) {
|
|
30
|
+ e.printStackTrace();
|
|
31
|
+ }
|
14
|
32
|
userDao.save();
|
15
|
33
|
}
|
16
|
34
|
}
|