2424import org .springframework .boot .autoconfigure .SpringBootApplication ;
2525import org .springframework .context .annotation .Bean ;
2626import org .springframework .stereotype .Controller ;
27- import org .springframework .web .bind .annotation .RequestMapping ;
28- import static javax .measure .unit .SI .KILOGRAM ;
29- import javax .measure .quantity .Mass ;
30- import org .jscience .physics .model .RelativisticModel ;
31- import org .jscience .physics .amount .Amount ;
27+ import org .springframework .web .bind .annotation .*;
3228
3329import javax .sql .DataSource ;
3430import java .sql .Connection ;
@@ -65,7 +61,7 @@ String db(Map<String, Object> model) {
6561 stmt .executeUpdate ("INSERT INTO ticks VALUES (now())" );
6662 ResultSet rs = stmt .executeQuery ("SELECT tick FROM ticks" );
6763
68- ArrayList <String > output = new ArrayList <String >();
64+ ArrayList <String > output = new ArrayList <>();
6965 while (rs .next ()) {
7066 output .add ("Read from DB: " + rs .getTimestamp ("tick" ));
7167 }
@@ -78,12 +74,19 @@ String db(Map<String, Object> model) {
7874 }
7975 }
8076
81- @ RequestMapping ("/hello" )
82- String hello (Map <String , Object > model ) {
83- RelativisticModel .select ();
84- Amount <Mass > m = Amount .valueOf ("12 GeV" ).to (KILOGRAM );
85- model .put ("science" , "E=mc^2: 12 GeV = " + m .toString ());
86- return "hello" ;
77+ //Save a account to the postgres DB
78+ @ PostMapping (value = "/save-account" )
79+ public @ ResponseBody
80+ boolean saveSfContact (@ RequestParam (name = "name" ) String name , @ RequestParam (name = "id" )String id ) {
81+ try (Connection connection = dataSource .getConnection ()) {
82+ Statement stmt = connection .createStatement ();
83+ stmt .executeUpdate ("update salesforcecgoconnect.account set salesforcecgoconnect.account.name= '" + name +"' where recordtypeid = '" + id + "'" );
84+ return true ;
85+ } catch (Exception e ) {
86+ e .printStackTrace ();
87+ return false ;
88+ }
89+
8790 }
8891
8992 @ Bean
0 commit comments