一、总体说明
本例运行演示了用Jersey构建RESTful服务中,如何同过Hibernate将数据持久化进SQLServer的过程
二、环境
1.上文的项目RestDemo
2.SQLServer2005
三、配置
与上文mysql的配置不同点主要在hibernate.cfg.xml文件;
配置如下:
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">net.sourceforge.jtds.jdbc.Driver</property>
<property name="connection.url">jdbc:jtds:sqlserver://192.168.1.10:1433;RestDemo</property>
<property name="connection.username">sa</property>
<property name="connection.password">aA123456</property>
<property name="hibernate.default_schema">RestDemo</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.internal.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">update</property>
<mapping resource="com/waylau/rest/bean/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
四、问题
可能会出现如下错误
ERROR: 指定的架构名称 "RestDemo" 不存在,或者您没有使用该名称的权限。
三月 26, 2014 3:38:43 下午 org.hibernate.tool.hbm2ddl.SchemaUpdate execute
INFO: HHH000232: Schema update complete
Hibernate: insert into RestDemo.T_USER (userName, age, USERID) values (?, ?, ?)
三月 26, 2014 3:38:43 下午 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 208, SQLState: S0002
三月 26, 2014 3:38:43 下午 org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: 对象名 'RestDemo.T_USER' 无效。
解决方案:
将配置文件中的“hibernate.default_schema”值修改为如下即可:
<property name="hibernate.default_schema">RestDemo.dbo</property>
或者去掉上面的配置,在“User.hbm.xml”修改如下
<class name="User" table="T_USER" schema="RestDemo.dbo">
分享到:
相关推荐
NULL 博文链接:https://liangyingying1117.iteye.com/blog/2155855
instrumented-restful-fast-request-pro-2023.1.7.1 可用版,亲测,可用。
Pandax是Go语言开源的企业级低代码物联网平台开发框架,基于go-restful+Vue3.0+TypeScript+vite3+element-Plus的前后端分离开发。支持设备管控,规则链,云组态,可视化大屏,报表设计器,表单设计器,代码生成器,...
Building-RESTful-Python-Web-Services, 构建 RESTful python Web服务的代码库,由Packt发布 #Building RESTful python Web服务 这是构建 RESTful python Web服务 插件的代码库,由Packt发布。 它包含了从开始到结束...
Java SpringBoot 课程 restful crud 实验资源 restful 风格的增删改查
管理系统系列--更完善的Spring+SpringMVC+Mybatis+easyUI后台管理系统(RESTful
它是一个功能强大的Restful API工具包插件,可以根据已有的方法快速生成接口调试用例。它有一个漂亮的界面来完成请求、检查服务器响应、存储你的API请求和导出API请求,该插件能帮助你在IDEA内更快更高效地调试API!...
提供restful风格的框架, 拥有客户端和服务端两部分, 具体实现功能代码需要自己添加。
laravel-restful-api-starter, 使用 Laravel 和MongoDB构建一个 RESTful API #Laravel Restful API启动程序现在查看一下 WIKI !欢迎捐赠对于代码和 doc: ) !是什么?这里启动器基于以下功能:Laravel 4.2: 使用轻...
Developing-Restful-Web-Services-with-Jersey-2-0
jersey构建简单的Restful服务!
资源来自pypi官网。 资源全名:flask-restful-swagger-3-0.2.0.tar.gz
PandaX是Go语言开源的企业级物联网平台低代码开发基座,基于go-restful+Vue3.0+TypeScript+vite3+element-Plus的前后端分离开发。支持设备管控,规则链,云组态,可视化大屏,报表设计器,表单设计器,代码生成器等...
Spring Hibernate, Jersey 创建restful 服务的例子 图文并茂,step by step
一个基于 fasttext + faiss 的商品内容相关推荐接口实现,restful接口采用nginx+uwsgi+flask,gunicorn+uvicorn+fastapi 增加Spark实现内容相关推荐,Ansj+Word2vec+LSH+Phoenix 商品详情页效果图 将模型部署应用
基于 Jersey 构建 RESTful 服务。 ---------------------------------------------------- 本 PDF 基于开源文档,目录书签齐全。 版权归原作者,翻译版权归译者。 -----------------------------------------------...
SpringBoot毕设资源--springboot+mybatis+restful实现论坛项目(毕业设计) SpringBoot毕设资源--springboot+mybatis+restful实现论坛项目(毕业设计) SpringBoot毕设资源--springboot+mybatis+restful实现论坛项目...
SAP-BO-Restful-SDK-开发指导手册
RESTFUL的实现-springboot2.0版本 网址:https://blog.csdn.net/chenwewi520feng/article/details/130634490 使用一个示例来说明restful的使用,是以springboot的2.0版本作为基础的