0

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
asked Jul 7, 2022 at 10:11

1 Answer 1

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

https://github.com/erayerdem/camel-test/blob/master/src/main/java/com/learncamel/routes/PostgresRoute.java

answered Jul 7, 2022 at 12:43
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.