Hi You should use the @user mailing list for your questions on using Camel and getting help, as we say here http://camel.apache.org/support http://camel.apache.org/mailing-lists.html
On Wed, Mar 20, 2013 at 1:48 PM, takidean <takide...@hotmail.fr> wrote: > i use to extract some information from an xml file to insert them into a jdbc > data base this is what i did and it doesn't work > > ******************main*********** > public class Cntx { > > /** > * @param args > * @throws Exception > */ > public static void main(String[] args) throws Exception { > // TODO Auto-generated method stub > CamelContext context = new DefaultCamelContext(); > context.addRoutes(new MyRouteBuilder()); > context.start(); > Thread.sleep(3000); > context.stop(); > } > > } > ***************MyrouteBuilder*********** > public class MyRouteBuilder extends RouteBuilder { > > /** > * Let's configure the Camel routing rules using Java code... > */ > public void configure() { > > // here is a sample which processes the input files > // (leaving them in place - see the 'noop' flag) > // then performs content based routing on the message using XPath > from("file:src/data") > .choice() > .when(xpath("/person/user = 'SFIN'")) > .to("bean:OrderToSql").to("bean:SfinPull"); > } > > } > *************OrderToSqlBean********** > public class OrderToSql { > > public String toSql(@XPath("order/@firstName") String name, > @XPath("order/@lastName") int amount, > @XPath("order/@city") String customer) { > StringBuilder sb = new StringBuilder(); > sb.append("insert into examen.user "); > sb.append("(name, lastname, city) values ("); > sb.append("'").append(name).append("', "); > sb.append("'").append(amount).append("', "); > sb.append("'").append(customer).append("') "); > return sb.toString(); > } > } > **************SfinPull*******/ > public class SfinPull { > > public void Pull(String s) throws SQLException, > ClassNotFoundException{ > > String url = "jdbc:mysql://localhost:3306/examen"; > String login = "root"; > String pass = ""; > Class.forName("com.mysql.jdbc.Driver"); > Connection connection = DriverManager.getConnection(url, login, > pass); > PreparedStatement ps=connection.prepareStatement(s); > ps.executeUpdate(); > > } > > } > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/insert-into-jdbc-don-t-work-tp5729501.html > Sent from the Camel Development mailing list archive at Nabble.com. -- Claus Ibsen ----------------- Red Hat, Inc. FuseSource is now part of Red Hat Email: cib...@redhat.com Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.com Author of Camel in Action: http://www.manning.com/ibsen