标签:io os 使用 java sp on cti bs new
tomcat里的conf->context.xml
<Resource name="mysql"
auth="Container" type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/test"
username="root"
password="123456"
maxActive="100"
maxIdle="30"
maxWait="10000"
/>
hibernate.cfg.xml
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">
java:comp/env/mysql
</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<mapping resource="com/dan/hibernate/Stu.hbm.xml" />
</session-factory>
使用
Configuration cf=new Configuration().configure();
SessionFactory sf=cf.buildSessionFactory();
Session session=sf.openSession();
Stu stu=(Stu) session.get(Stu.class, 1);
out.println(stu.getId());
标签:io os 使用 java sp on cti bs new
原文地址:http://www.cnblogs.com/danmao/p/4038875.html