mybatis+mysql

(一)mysql的配置:

drvername:com.mysql.jdbc.Driver

url:jdbc:mysql://localhost:3360/数据库名

mysql user:XXXX

mysql password:XXXX

(二)数据库连接:

Reader reader=Resources.getResourceAsReader("conf.xml");

SqlSessionFactory sessionFactory-new SqlSessionFactoryBuilder().build(reader);

SqlSession session=sessionFactory.openSession();

String statement="org.XXXX.entiry.XXXMapper.Selectid";

AA  a=session.selectOne(statement,1);

System.out.println(a);

session.close();

你可能感兴趣的:(mybatis+mysql)