SSH support for clob Field Types

Source: Internet
Author: User

Environment:

1. Oracle 9i 9.2.0.8.0

2. JDBC: ojdbc5.jar

3. Spring 2

4. hibernate 3

 

There is an information management module in the system. The information content is edited using FCKeditor, And the content may be very long. Therefore, we decided to change the field type from varchar2 to clob.

 

Query data online. It is said that JDBC of Oracle 10g and 1.4 and later versions supports direct clob ing using string. The configuration is as follows:

  • JDBC configuration of Hibernate

 

{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ closed_text_161132 '). style. display = 'none'; document. getelementbyid ('Code _ open_image_161132 '). style. display = 'inline'; document. getelementbyid ('Code _ open_text_161132 '). style. display = 'inline ';
}
}
}
} "Id =" code_closed_image_161132 "style =" display: none "> {
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ open_text_161132 '). style. display = 'none'; getelementbyid ('Code _ closed_image_161132 '). style. display = 'inline'; getelementbyid ('Code _ closed_text_161132 '). style. display = 'inline ';
}
}
}
} "Id =" code_open_image_161132 "> code
<Property name = "hibernate. Connection. setbigstringtryclob"> true </property>

  • Hibernate ing File

 

{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ closed_text_161205 '). style. display = 'none'; document. getelementbyid ('Code _ open_image_161205 '). style. display = 'inline'; document. getelementbyid ('Code _ open_text_161205 '). style. display = 'inline ';
}
}
}
} "Id =" code_closed_image_161205 "style =" display: none "> {
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ open_text_161205 '). style. display = 'none'; getelementbyid ('Code _ closed_image_161205 '). style. display = 'inline'; getelementbyid ('Code _ closed_text_161205 '). style. display = 'inline ';
}
}
}
} "Id =" code_open_image_161205 "> code
<Property name = "clobcontent" type = "text" column = "v_content"> </property>

  • Entity class

 

{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ closed_text_161235 '). style. display = 'none'; document. getelementbyid ('Code _ open_image_161235 '). style. display = 'inline'; document. getelementbyid ('Code _ open_text_161235 '). style. display = 'inline ';
}
}
}
} "Id =" code_closed_image_161235 "style =" display: none "> {
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ open_text_161235 '). style. display = 'none'; getelementbyid ('Code _ closed_image_161235 '). style. display = 'inline'; getelementbyid ('Code _ closed_text_161235 '). style. display = 'inline ';
}
}
}
} "Id =" code_open_image_161235 "> code
Private string clobcontent;

 

For details, see the use of the clob field in hibernate.

Unfortunately, our environment does not support this simple configuration. After many queries and experiments, I adopted spring support. The configuration is as follows:

  • Spring configuration file

 

{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ closed_text_161311 '). style. display = 'none'; document. getelementbyid ('Code _ open_image_161311 '). style. display = 'inline'; document. getelementbyid ('Code _ open_text_161311 '). style. display = 'inline ';
}
}
}
} "Id =" code_closed_image_161311 "style =" display: none "> {
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ open_text_161311 '). style. display = 'none'; getelementbyid ('Code _ closed_image_161311 '). style. display = 'inline'; getelementbyid ('Code _ closed_text_161311 '). style. display = 'inline ';
}
}
}
} "Id =" code_open_image_161311 "> code
<! -- Support for Database BLOB and clob fields -->
<Bean id = "nativejdbcextractor" class = "org. springframework. JDBC. Support. nativejdbc. simplenativejdbcextractor" lazy-init = "true">
</Bean>
<Bean id = "lobhandler" class = "org. springframework. JDBC. Support. lob. oraclelobhandler" lazy-init = "true">
<Property name = "nativejdbcextractor">
<Ref local = "nativejdbcextractor"/>
</Property>
</Bean>

<Bean id = "sessionfactory" class = "org. springframework. Orm. hibernate3.localsessionfactorybean">
<Property name = "datasource" ref = "app_ds"/>

<! -- Support for Database BLOB and clob fields -->
<Property name = "lobhandler">
<Ref local = "lobhandler"/>
</Property>

 

  • Hibernate ing File

 

{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ closed_text_161339 '). style. display = 'none'; document. getelementbyid ('Code _ open_image_161339 '). style. display = 'inline'; document. getelementbyid ('Code _ open_text_161339 '). style. display = 'inline ';
}
}
}
} "Id =" code_closed_image_161339 "style =" display: none "> {
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ open_text_161339 '). style. display = 'none'; getelementbyid ('Code _ closed_image_161339 '). style. display = 'inline'; getelementbyid ('Code _ closed_text_161339 '). style. display = 'inline ';
}
}
}
} "Id =" code_open_image_161339 "> code
<Property name = "clobcontent" type = "org. springframework. Orm. hibernate3.support. clobstringtype" column = "v_content"> </property>

 

  • Entity class

 

{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ closed_text_161355 '). style. display = 'none'; document. getelementbyid ('Code _ open_image_161355 '). style. display = 'inline'; document. getelementbyid ('Code _ open_text_161355 '). style. display = 'inline ';
}
}
}
} "Id =" code_closed_image_161355 "style =" display: none "> {
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ open_text_161355 '). style. display = 'none'; getelementbyid ('Code _ closed_image_161355 '). style. display = 'inline'; getelementbyid ('Code _ closed_text_161355 '). style. display = 'inline ';
}
}
}
} "Id =" code_open_image_161355 "> code
Private string clobcontent;

 

 

After this configuration, it can run normally without modifying the code.

 

Appendix:

1. The JDBC version is very important. At first, we threw two drivers named classes12.jar and ojdbc5.jar under Lib. classes12.jar is always at work and there is no problem in reading data during debugging, however, the error "unable to read more data from the socket" is reported when writing data. After this package is deleted, it runs normally.

2. SQL statement for varchar2 to clob

 

{
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ closed_text_161412 '). style. display = 'none'; document. getelementbyid ('Code _ open_image_161412 '). style. display = 'inline'; document. getelementbyid ('Code _ open_text_161412 '). style. display = 'inline ';
}
}
}
} "Id =" code_closed_image_161412 "style =" display: none "> {
Function onclick ()
{
Function onclick ()
{
Function onclick ()
{
This. style. display = 'none'; document. getelementbyid ('Code _ open_text_161412 '). style. display = 'none'; getelementbyid ('Code _ closed_image_161412 '). style. display = 'inline'; getelementbyid ('Code _ closed_text_161412 '). style. display = 'inline ';
}
}
}
} "Id =" code_open_image_161412 "> code
Alter table tb_base_policy
Add (v_content1 clob );

Update tb_base_policy
Set v_content1 = v_content;

Alter table tb_base_policy drop column v_content;

Alter table tb_base_policy
Rename column v_content1 to v_content;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.