Home> Java> JavaBase> body text

Solution to Java reading oracle garbled code

Release: 2019-12-02 15:25:58
Original
2358 people have browsed it

Solution to Java reading oracle garbled code

When Java reads Oracle and encounters Chinese garbled characters, we need to transcode. (Recommended:java video tutorial)

Transcoding method:

1. Pure manual transcoding

Convert the read string s Code, such as: new String(s.getByte(A), B)

2, Druid

druid is a driver developed by Alibaba itself. It is actually a driver for various databases. It provides a unified layer of encapsulation and adds functions such as logs, alarms, and code conversion. The configuration method is as follows:

     serverEncoding=ISO-8859-1;clientEncoding=GBK;defaultRowPrefetch=50;bigStringTryClob=true 
Copy after login

The connectionProperties contains two properties: serverEncoding and clientEncoding. After Java reads the data, if it is found that serverEncoding and clientEncoding are different, the following encoding conversion will be automatically performed.

new String(s.getByte(serverEncoding), clientEncoding)
Copy after login

For more java knowledge, please pay attention to thejava basic tutorialcolumn.

The above is the detailed content of Solution to Java reading oracle garbled code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!