Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package zll; import java.io.IOException; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import zll.entity.Customer; import zll.swing.util.MybatisUtil; /** * * @author hh-zhujb */ public class MybatisTest { public static void main(String args[]) throws IOException { SqlSessionFactory sqlSessionFactory = MybatisUtil.getSessionFactory(); SqlSession session = sqlSessionFactory.openSession(); try { // do work Customer c = session.selectOne("Customer.list"); if (c == null) { System.out.print("empty"); } else { System.out.print("not empty"); System.out.println(c.getName()); } session.commit(); } finally { session.close(); } } }