Update JDBCDemo.java

71和76行测试示例的数据库和表名没有动态拼接,测试用在前面改数据库名和表名,会导致运行报错
This commit is contained in:
nianhongdong 2021-03-31 13:46:01 +08:00 committed by GitHub
parent 3fca391bf1
commit 61d7d9ab41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -68,12 +68,12 @@ public class JDBCDemo {
}
private void insert() {
final String sql = "insert into test.weather (ts, temperature, humidity) values(now, 20.5, 34)";
final String sql = "insert into " + dbName + "." + tbName + " (ts, temperature, humidity) values(now, 20.5, 34)";
exuete(sql);
}
private void select() {
final String sql = "select * from test.weather";
final String sql = "select * from "+ dbName + "." + tbName;
executeQuery(sql);
}