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:
<bean id="opensqlDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="com.alibaba.china.jdbc.SimpleDriver" /> <property name="url" value="jdbc:oracle:thin:@10.20.130.210:1521:dwtest" /> <property name="username" value="etl" /> <property name="password" value="etl" /> <property name="connectionProperties"><value>serverEncoding=ISO-8859-1;clientEncoding=GBK;defaultRowPrefetch=50;bigStringTryClob=true</value></property> </bean>
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)
For more java knowledge, please pay attention to the java basic tutorial column.
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

WebStorm Mac version
Useful JavaScript development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Dreamweaver Mac version
Visual web development tools

Atom editor mac version download
The most popular open source editor
