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/bean-dont-work-tp5729509.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply via email to