| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | package info.xiaomo.multipleSource.controller; | |
| 2 | 2 | ||
| 3 | 3 | import info.xiaomo.core.controller.Result; | |
| 4 | + import info.xiaomo.multipleSource.sql.Sql; | ||
| 4 | 5 | import org.springframework.beans.factory.annotation.Autowired; | |
| 5 | 6 | import org.springframework.beans.factory.annotation.Qualifier; | |
| 6 | 7 | import org.springframework.jdbc.core.JdbcTemplate; | |
@@ -40,11 +41,11 @@ public MultipleSourceController(@Qualifier("primaryJdbcTemplate") JdbcTemplate j | |||
| 40 | 41 | @RequestMapping("/") | |
| 41 | 42 | public Result index() { | |
| 42 | 43 | // 往第一个数据源中插入两条数据 | |
| 43 | - jdbcTemplate1.update("insert into user(name,age) values(?, ?)", "xiaomo", 20); | ||
| 44 | - jdbcTemplate2.update("insert into user(name,age) values(?, ?)", "xiaoming", 30); | ||
| 44 | + jdbcTemplate1.update(Sql.addUser1, "xiaomo", 20); | ||
| 45 | + jdbcTemplate2.update(Sql.addUser1, "xiaoming", 30); | ||
| 45 | 46 | ||
| 46 | - int count1 = jdbcTemplate1.queryForObject("select count(1) from user", Integer.class); | ||
| 47 | - int count2 = jdbcTemplate2.queryForObject("select count(1) from user", Integer.class); | ||
| 47 | + int count1 = jdbcTemplate1.queryForObject(Sql.selectUser1, Integer.class); | ||
| 48 | + int count2 = jdbcTemplate2.queryForObject(Sql.selectUser2, Integer.class); | ||
| 48 | 49 | return new Result(new Object[]{count1, count2}); | |
| 49 | 50 | } | |
| 50 | 51 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,26 @@ | |||
| 1 | + package info.xiaomo.multipleSource.sql; | ||
| 2 | + | ||
| 3 | + /** | ||
| 4 | + * 把今天最好的表现当作明天最新的起点..~ | ||
| 5 | + * いま 最高の表現 として 明日最新の始発..~ | ||
| 6 | + * Today the best performance as tomorrow newest starter! | ||
| 7 | + * Created by IntelliJ IDEA. | ||
| 8 | + * | ||
| 9 | + * @author: xiaomo | ||
| 10 | + * @github: https://github.com/qq83387856 | ||
| 11 | + * @email: hupengbest@163.com | ||
| 12 | + * @QQ_NO: 83387856 | ||
| 13 | + * @Date: 2016/11/16 11:29 | ||
| 14 | + * @Description: 用户实体类 | ||
| 15 | + * @Copyright(©) 2015 by xiaomo. | ||
| 16 | + **/ | ||
| 17 | + | ||
| 18 | + public class Sql { | ||
| 19 | + | ||
| 20 | + public static String addUser1= "insert into user(name,age) values(?, ?)"; | ||
| 21 | + public static String addUser2= "insert into user(name,age) values(?, ?)"; | ||
| 22 | + | ||
| 23 | + public static String selectUser1 = "select count(1) from user"; | ||
| 24 | + public static String selectUser2 = "select count(1) from user"; | ||
| 25 | + | ||
| 26 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments