<code id="ymukc"><xmp id="ymukc">

spring+spring mvc+mybatis

felixilef的頭像 felixilef 0 2016-03-06 13:10 1

 基本信息

× 1   

瀏覽數: 28996

分享時間: 2 年 前

3

[Java]代碼    

package com.mytest.tesst;

import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import com.mytest.beans.User;

public class MyBatisTest {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		String resource = "mybatis_config.xml";
//		com.mysql.jdbc.Driver
		InputStream is = MyBatisTest.class.getClassLoader().getResourceAsStream(resource);
		SqlSessionFactory sessionFactory = new SqlSessionFactoryBuilder().build(is);
		SqlSession session = sessionFactory.openSession();
		String statement = "com.mytest.dao.UserDao.getUser";//獲取對應的sql替換
        //?查詢sql,獲取結果,通過id去查詢用戶
        User user = session.selectOne(statement, 1);
        System.out.println(user);
        //查詢列表
        List<User> userList = session.selectList("com.mytest.dao.UserDao.getList");
        System.out.println("user_count:"+userList.size());
        Map<String,String> map = new HashMap<String,String>();
        map.put("name", "123");
        map.put("age", "1234");
        User user1 = session.selectOne("com.mytest.dao.UserDao.getUserByMap", map );
        System.out.println("user1:"+user1);
	}

}

12 3 [下一頁]

  • shihunga的頭像 shihunga 2016-12-26 11:28 代碼數:0

    參考學習下, 剛入門

  • pevahanifo的頭像 pevahanifo 2018-10-20 18:09 代碼數:0

    I was looking at some of your posts on this website and I conceive this web site is really instructive! Keep putting up.. Megabucks Ranch

  • weclch2008的頭像 weclch2008 2016-05-10 13:51 代碼數:0

    這個代碼還是有一定的參考價值的!

  • ossaa的頭像 ossaa 2018-10-21 18:39 代碼數:0

    I know your expertise on this. I must say we should have an online discussion on this. Writing only comments will close the discussion straight away! And will restrict the benefits from this information.Enjoy Mexico Villa Rentals

  • ossaa的頭像 ossaa 2018-10-21 21:41 代碼數:0

    I’ve been searching for some decent stuff on the subject and haven't had any luck up until this point, You just got a new biggest fan!..

    Enjoy Mexico top desinations

  • ossaa的頭像 ossaa 2018-10-22 17:21 代碼數:0

    i read a lot of stuff and i found that the way of writing to clearifing that exactly want to say was very good so i am impressed and ilike to come again in future.. 

    Enjoy Mexico Villa Rentals in Cabo San Lucas

  • ossaa的頭像 ossaa 2018-10-22 20:04 代碼數:0

    I admit, I have not been on this web page in a long time... however it was another joy to see It is such an important topic and ignored by so many, even professionals. professionals. I thank you to help making people more aware of possible issues.

    Enjoy Mexico Villa Rentals in Punta Mita

  • ossaa的頭像 ossaa 2018-10-22 21:58 代碼數:0

    Thanks for posting this info. I just want to let you know that I just check out your site and I find it very interesting and informative. I can't wait to read lots of your posts.

    iepnw.com

  • ossaa的頭像 ossaa 2018-10-31 16:40 代碼數:0

    This is such a great resource that you are providing and you give it away for free. I love seeing websites that understand the value of providing a quality resource for free. It is the old what goes around comes around routine.

    Poster Displays

  • ossaa的頭像 ossaa 2018-11-01 19:25 代碼數:0

    I recently came across your blog and have been reading along. I thought I would leave my first comment. I don't know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

    SEO Agentur Ruhrgebiet

您的評論:

  
六合特码资料
<code id="ymukc"><xmp id="ymukc">
<code id="ymukc"><xmp id="ymukc">