Commit 51839277 by BrianHolsen

a

parent 4447ee86
package com.bbdtek.test.controller;
import org.omg.CORBA.INTERNAL;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.validation.Errors;
import org.springframework.validation.FieldError;
import org.springframework.validation.ObjectError;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import org.springframework.validation.Validator;
import java.util.List;
/**
* Created by BrianHolsen on 2017-08-02 at 16:14.
*/
@RequestMapping("/test")
@RestController
public class TestController {
//@Autowired
//private Validator validator = new org.springframework.validation.beanvalidation.LocalValidatorFactoryBean();
@Autowired
private JdbcTemplate jdbcTemplate;
@RequestMapping("hi")
public String hi() {
return "host=" + System.getenv("MYSQL_SERVICE_HOST") + "; "
+ "username=" + System.getenv("MYSQL_USERNAME") + "; "
+ "password=" + System.getenv("MYSQL_PASSWORD") + "; ";
}
@RequestMapping("createTable")
public String createTable() {
this.jdbcTemplate.execute("CREATE TABLE DATA (ID INT PRIMARY KEY , NAME VARCHAR(50))");
return "OK";
}
@RequestMapping("generateData")
public String generateData() {
int count = 0;
count += this.jdbcTemplate.update("INSERT INTO DATA(ID,NAME) VALUES(1,\"BRIAN\")");
count += this.jdbcTemplate.update("INSERT INTO DATA(ID,NAME) VALUES(2,\"HOLSEN\")");
return "res: " + count;
}
@RequestMapping("getById")
public String getById(int id) {
String name = this.jdbcTemplate.queryForObject("SELECT NAME FROM DATA WHERE ID=" + id, String.class);
if (name == null) {
return "NOT FOUND";
} else {
return "name is: " + name;
}
}
}
jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://#{systemEnvironment[systemEnvironment['DB_SERVICE_NAME'].replace('-','_').toUpperCase()+"_SERVICE_HOST"]}/#{systemEnvironment['MYSQL_DATABASE']}?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
jdbc.url=jdbc:mysql://#{systemEnvironment[systemEnvironment['DB_SERVICE_NAME'].replace('-','_').toUpperCase()+"_SERVICE_HOST"]}:#{systemEnvironment[systemEnvironment['DB_SERVICE_NAME'].replace('-','_').toUpperCase()+"_SERVICE_PORT"]}/#{systemEnvironment['MYSQL_DATABASE']}?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
jdbc.username=#{systemEnvironment['MYSQL_USERNAME']}
jdbc.password=#{systemEnvironment['MYSQL_PASSWORD']}
#jdbc.url=jdbc:mysql://127.0.0.1:3306/ejweb?useUnicode=true&characterEncoding=utf-8&zeroDateTimeBehavior=convertToNull
#jdbc.username=root
#jdbc.password=root
#\u521d\u59cb\u5316\u8fde\u63a5
jdbc.initialSize=10
#\u6700\u5927\u8fde\u63a5\u6570\u91cf\uff0c\u8bbe\u7f6e\u4e3a0\u65f6\uff0c\u8868\u793a\u6ca1\u6709\u9650\u5236
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment