Last active
June 19, 2020 06:42
-
-
Save jeffreycassar/ad458b632cfc52ae9b58d5a7488bb99c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class InsertPersonMessageProcessor implements MessageProcessor { | |
@Autowired | |
private DataSource dataSource; | |
@Override | |
public MuleEvent process(MuleEvent event) throws MuleException { | |
Map<String, Object> personInfo = event.getFlowVariable("personInfo"); | |
Connection connection; | |
try { | |
connection = dataSource.getConnection(); | |
DSLContext dslContext = DSL.using(connection, SQLDialect.DEFAULT); | |
dslContext.insertInto(DSL.table("People")) | |
.columns(DSL.field("firstname"), DSL.field("lastname"), DSL.field("age")) | |
.values(personInfo.get("firstname"), personInfo.get("lastname"), personInfo.get("age")) | |
.execute(); | |
} catch (SQLException e) { | |
throw new RuntimeException(e); | |
} | |
return event; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment