日期:2014-05-18 浏览次数:21043 次
<Context path="/HibernateDataSource" docBase="HibernateDataSource"
debug="5" reloadable="true" crossContext="true">
<Resource name="jdbc/myhibernate"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="sa"
password="111111"
driverClassName="com.microsoft.jdbc.sqlserver.SQLServerDriver"
url="jdbc:microsoft:sqlserver://localhost:1433;databasename=person"/>
</Context>
public SessionFactory getSessionFactory(){
SessionFactory sf = null;
String jndi = "jdbc/myhibernate";
try {
//Context ctx = new InitialContext();
//sf = (SessionFactory)ctx.lookup(jndi);System.out.println("sf===="+sf);
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
sf = (SessionFactory) envCtx.lookup(jndi);
} catch (NamingException e) {
e.printStackTrace();
}
return sf;
}
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!-- Generated by MyEclipse Hibernate Tools. -->
<hibernate-configuration>
<!-- http://hao.com/html/down/index.html -->
<session-factory name="jdbc/myhibernate">
<!--<property name="connection.username">sa</property>
<property name="connection.url">
jdbc:microsoft:sqlserver://localhost:1433;databasename=person
</property>
<property name="dialect">
org.hibernate.dialect.SQLServerDialect
</property>
<property name="myeclipse.connection.profile">MSSQL</property>
<property name="connection.password">111111</property>
<property name="hibernate.connection.pool.size">50</property>
-->
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<property name="connection.datasource">
java:comp/env/jdbc/myhibernate
</property>
<property name="show_sql">true</property>
<property name="jndi.url"></property>
<mapping resource="org/shirdrn/entity/Person.hbm.xml" />
</session-factory>
</hibernate-configuration>
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws
寻求人力资源网,该如何解决