I am learning to use Apache Camel.
So far I've been trying to create execute a very simple SQL request which seems to not be working. I hope any of you can tell me what is wrong with the code.
Thank you for any potential input.
public class CamelMain {
public static void main(String... args) throws Exception {
Main camelMain = new Main();
camelMain.configure().addRoutesBuilder(createBasicRoute());
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.postgresql.Driver");
dataSource.setUrl("jdbc:postgresql://localhost:9201/dbname");
dataSource.setUsername("username");
dataSource.setPassword("password");
camelMain.bind("myDataSource",dataSource);
camelMain.run(args);
}
static RouteBuilder createBasicRoute() {
return new RouteBuilder() {
@Override
public void configure() {
from("direct:query")
.to("sql:insert into FileDetailTable (filename, Status, createdAt) values ('test', 'test', 'test')?dataSource=#myDataSource");
}
};
}
}
can u remove # symbol and try again
if u get still error can your try this example
main method
https://github.com/erayerdem/camel-test/blob/master/src/main/java/com/learncamel/routes/Test.java
postgresql route
https://github.com/erayerdem/camel-test/blob/master/src/main/java/com/learncamel/routes/PostgresRoute.java