找传奇、传世资源到传世资源站!

轻量级持久层框架_

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

import java.util.List;

 

import com.lq.util.jdbc.Jdbc;

import com.lq.util.jdbc.LqGoEntity;

import com.lq.util.jdbc.LqGoInsertAndUpdateAndSelect;

import com.lq.util.jdbc.LqJdbcFactory;

import com.lq.util.jdbc.LqShiWu;

import com.lq.util.jdbc.Page;

 

 

public class Test {

    public static void main(String[] args) {

        //SQL SERVER 2005 分页

        Page page=Jdbc.findPage("SELECT ROW_NUMBER() OVER (ORDER BY id) AS RowNumber,* from payinfo", 1, 3, "select count(*) from payinfo", new Object[]{});

        System.out.println(page.getData().size());

         

        new LqGoEntity(

            "com.lq.util.jdbc",

            "payinfo",

            "jdbc:microsoft:sqlserver://www.zhongziyun.com:1433;DatabaseName=zhongziyun***admin***123",

            "com.microsoft.jdbc.sqlserver.SQLServerDriver"

        );

         

        new LqGoEntity(

            "com.lq.util.jdbc",

            "t_user",

            "jdbc:mysql://www.zhongziyun.com/zhongziyun?useOldAliasMetadataBehavior\\=true&useUnicode\\=true&characterEncoding\\=utf-8***root***888888",

            "com.mysql.jdbc.Driver"

        );

         

        new LqGoEntity(

            "com.lq.util.jdbc",

            "base_data_product",

            "jdbc:oracle:thin:@www.zhongziyun.com:1521:orcl***zhongziyun***123",

            "oracle.jdbc.driver.OracleDriver"

        );

    }

     

     

     

    public void shuoM(){

        /**

         * 生成实体类

         */

        new LqGoEntity(

            "com.entity",

            "t_user",

            "jdbc:mysql://192.168.1.39/dingcan?useOldAliasMetadataBehavior\\=true&useUnicode\\=true&characterEncoding\\=utf-8***root***888888",

            "com.mysql.jdbc.Driver"

        );

        /**

         * 生成插入修改SQL语句

         */

        new LqGoInsertAndUpdateAndSelect(

                "t_user", 

                "jdbc:mysql://192.168.1.39/dingcan?useOldAliasMetadataBehavior\\=true&useUnicode\\=true&characterEncoding\\=utf-8***root***888888",

                "com.mysql.jdbc.Driver"

        );

         

        //-------------------------下面为SQL语句操作----------------------------------------

         

        /**

         * 查询

         */

        Jdbc.find("select * from t_user where id=?", new Object[]{"1"});

        /**

         * 分页查询

         */

        Page page=Jdbc.findPage("select * from t_user where id=?", 1, 15, "select count(id) from t_user where id=?", new Object[]{"1"});

        /**

         * 插入

         */

        Jdbc.execute("insert into test (name)values(?)", new Object[]{"吃人的肉"});

        /**

         * 修改

         */

        Jdbc.execute("update test set name=? where id=?", new Object[]{"吃人的肉1","1"});

        /**

         * 删除

         */

        Jdbc.execute("delete from test where id=?",new Object[]{"1"});

         

        //------------------------下面为实体类操作------------------------------------------

         

        final Test test=new Test();

        Jdbc.save(test);//插入

        Jdbc.update(test);//修改

        Jdbc.delete(test);//删除

        List<Test> list=Jdbc.find("select * from t_user", Test.class, new Object[]{});//查询返回实体类

         

        //------------------------下面为事务操作------------------------------------------

         

        /**

         * 事务处理

         */

        Jdbc.shiwu(new LqShiWu() {

            @Override

            public void shiwu(LqJdbcFactory jdbc) {

                jdbc.find("select * from t_user where id=?", new Object[]{"1"});

                jdbc.execute("insert into test (name)values(?)", new Object[]{"吃人的肉"});

                jdbc.execute("update test set name=? where id=?", new Object[]{"吃人的肉1","1"});

                jdbc.execute("delete from test where id=?",new Object[]{"1"});

                Jdbc.save(test);//插入

                Jdbc.update(test);//修改

                Jdbc.delete(test);//删除

            }

        });

    }

}

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复