我下载H3 把hibernate3.jar和lib下的所有文件都放在了Tomcat的一个应用web-inf/lib下然后在classes目录下创建了hibernate-cfg.xml文件 内容如下:<?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"><hibernate-configuration>
<session-factory>
<property name="hibernate.connection.url">
jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=MySql
</property>
<property name="hibernate.connection.driver_class">
com.microsoft.jdbc.sqlserver.SQLServerDriver
</property>
<property name="hibernate.connection.username">
sa
</property>
<property name="hibernate.connection.password">
123
</property>
<property name="dialect">
org.hibernate.dialect.SybaseDialect
</property>
<property name="show_sql">
True
</property>
<property name="hibernate.use_outer_join">
True
</property>
<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory
</property>
<mapping resource="org/mytest/hibernate/Mytable.hbm.xml"/>
</session-factory>
</hibernate-configuration>然后写了一段测试程序,如下package test.hibernate.servlet;import javax.servlet.*;
import javax.servlet.http.*;
import org.hibernate.*;
import org.hibernate.cfg.*;
import org.mytest.hibernate.*;
import java.io.*;public class TestOne extends HttpServlet{
private static final long serialVersionUID = 1;
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
response.setContentType("text/html;charset=gb2312");
try{
Configuration config = new Configuration().configure();
config.addClass(Mytable.class);
SessionFactory sessionFactory = config.buildSessionFactory();
sessionFactory.close();
response.sendRedirect("index.jsp");
}
catch (HibernateException e) {
response.sendRedirect("error.jsp");
}
catch(Exception e){
response.sendRedirect("error2.jsp");
}
finally{
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
doPost(request,response);
}}发现每次都抛出了HibernateException错误为什么我创建不了SessionFactory啊 ,请教教我
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"><hibernate-configuration>
<session-factory>
<property name="hibernate.connection.url">
jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=MySql
</property>
<property name="hibernate.connection.driver_class">
com.microsoft.jdbc.sqlserver.SQLServerDriver
</property>
<property name="hibernate.connection.username">
sa
</property>
<property name="hibernate.connection.password">
123
</property>
<property name="dialect">
org.hibernate.dialect.SybaseDialect
</property>
<property name="show_sql">
True
</property>
<property name="hibernate.use_outer_join">
True
</property>
<property name="hibernate.transaction.factory_class">
org.hibernate.transaction.JDBCTransactionFactory
</property>
<mapping resource="org/mytest/hibernate/Mytable.hbm.xml"/>
</session-factory>
</hibernate-configuration>然后写了一段测试程序,如下package test.hibernate.servlet;import javax.servlet.*;
import javax.servlet.http.*;
import org.hibernate.*;
import org.hibernate.cfg.*;
import org.mytest.hibernate.*;
import java.io.*;public class TestOne extends HttpServlet{
private static final long serialVersionUID = 1;
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
response.setContentType("text/html;charset=gb2312");
try{
Configuration config = new Configuration().configure();
config.addClass(Mytable.class);
SessionFactory sessionFactory = config.buildSessionFactory();
sessionFactory.close();
response.sendRedirect("index.jsp");
}
catch (HibernateException e) {
response.sendRedirect("error.jsp");
}
catch(Exception e){
response.sendRedirect("error2.jsp");
}
finally{
}
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException,IOException{
doPost(request,response);
}}发现每次都抛出了HibernateException错误为什么我创建不了SessionFactory啊 ,请教教我
解决方案 »
- Java程序员简历,请大师指点(去上海)
- 怎么样实现不刷新页面就能提交表单
- 学习之路
- j2ee 项目开发过程.完整的实例.请提供一份参考.
- 关于JSP站解析为HTML的问题探讨
- 请各位仁兄发表见解
- 关于JDBC连接MS SQL Server的问题? 请教高手!
- 谁能介绍一个专业的JavaBean的开发工具,开源的最好!
- resin的问题http can't bind to *:8080. Check for conflicting servers
- 我在bea.com下载的WebLogicServer在Solaris下安装成功,但怎么才能启动呢?
- 有熟悉struts的大虾吗?
- 关于最简单的hibernate的问题!!!!!!
Hibernate的方言和数据库不匹配,怎么能正确呢?????
我查阅了Hibernate3.jar下的包
没有发现MSSQL名称的是否是用SQLServerDialet
我改成了SQLServletDialet还是照样抛出HibernateException....到底为什么