Package org.sql2o

Examples of org.sql2o.Query.addParameter()


        Random r = new Random();

        Query insQuery = sql2o.createQuery("insert into post (text, creation_date, last_change_date, counter1, counter2, counter3, counter4, counter5, counter6, counter7, counter8, counter9) values (:text, :creation_date, :last_change_date, :counter1, :counter2, :counter3, :counter4, :counter5, :counter6, :counter7, :counter8, :counter9)");
        for (int idx = 0; idx < ITERATIONS; idx++)
        {
            insQuery.addParameter("text", "a name " + idx)
                    .addParameter("creation_date", new DateTime(System.currentTimeMillis() + r.nextInt()).toDate())
                    .addParameter("last_change_date", new DateTime(System.currentTimeMillis() + r.nextInt()).toDate())
                    .addParameter("counter1", r.nextDouble() > 0.5 ? r.nextInt() : null)
                    .addParameter("counter2", r.nextDouble() > 0.5 ? r.nextInt() : null)
                    .addParameter("counter3", r.nextDouble() > 0.5 ? r.nextInt() : null)
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.