提交 7f147e05 编写于 作者: Z zyyang

change

上级 3ce01a27
package com.taosdata.taosdemo.dao; package com.taosdata.taosdemo.dao;
import com.taosdata.taosdemo.utils.SqlSpeller; import com.taosdata.taosdemo.utils.SqlSpeller;
import org.apache.log4j.Logger;
import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.JdbcTemplate;
import javax.sql.DataSource; import javax.sql.DataSource;
import java.util.Map; import java.util.Map;
public class DatabaseMapperImpl implements DatabaseMapper { public class DatabaseMapperImpl implements DatabaseMapper {
private static final Logger logger = Logger.getLogger(DatabaseMapperImpl.class);
private final JdbcTemplate jdbcTemplate; private final JdbcTemplate jdbcTemplate;
...@@ -17,21 +19,29 @@ public class DatabaseMapperImpl implements DatabaseMapper { ...@@ -17,21 +19,29 @@ public class DatabaseMapperImpl implements DatabaseMapper {
@Override @Override
public void createDatabase(String dbname) { public void createDatabase(String dbname) {
jdbcTemplate.execute("create database if not exists " + dbname); String sql = "create database if not exists " + dbname;
jdbcTemplate.execute(sql);
logger.info("SQL >>> " + sql);
} }
@Override @Override
public void dropDatabase(String dbname) { public void dropDatabase(String dbname) {
jdbcTemplate.update("drop database if exists " + dbname); String sql = "drop database if exists " + dbname;
jdbcTemplate.update(sql);
logger.info("SQL >>> " + sql);
} }
@Override @Override
public void createDatabaseWithParameters(Map<String, String> map) { public void createDatabaseWithParameters(Map<String, String> map) {
jdbcTemplate.execute(SqlSpeller.createDatabase(map)); String sql = SqlSpeller.createDatabase(map);
jdbcTemplate.execute(sql);
logger.info("SQL >>> " + sql);
} }
@Override @Override
public void useDatabase(String dbname) { public void useDatabase(String dbname) {
jdbcTemplate.execute("use " + dbname); String sql = "use " + dbname;
jdbcTemplate.execute(sql);
logger.info("SQL >>> " + sql);
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册