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");
}
};
}
}
Olaf Kock
48.3k9 gold badges63 silver badges91 bronze badges
1 Answer 1
can u remove # symbol and try again
.to("sql:insert into FileDetailTable (filename, Status, createdAt) values ('test', 'test', 'test')?dataSource=myDataSource");
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
Sign up to request clarification or add additional context in comments.
Comments
Explore related questions
See similar questions with these tags.
lang-sql