- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在从 Oracle Database 12c 获取阿拉伯语内容时遇到问题,我已经关注了大多数已回答的问题,但没有任何效果。
我的阿拉伯字符返回这样的“????”
即使在 java 上,当我获取数据时它也不会返回阿拉伯值
{
"employees":[
{
"fname":"????",
"lname":"Saleh",
"amount":30000,
"phone":"96600000097"
},
{
"fname":"Saleh",
"lname":"Salem",
"amount":40000,
"phone":"96600000097"
},
{
"fname":"Hasan",
"lname":"Damis",
"amount":25000,
"phone":"96600000097"
},
{
"fname":"Ahmad",
"lname":"?????",
"amount":25000,
"phone":"96600000097"
},
{
"fname":"Abbas",
"lname":"Motwali",
"amount":20000,
"phone":"96600000097"
}
]
}
当我使用 sql developer 时,我可以 SELECT
, INSERT
阿拉伯值(value)观
我在笔记本电脑上使用 oracle 进行学习:
我在这里和互联网上发现了很多问题,例如:
但不幸的是我不能在sqlplus上使用这个命令
SHUTDOWN IMMEDIATE
它返回这个错误信息
ORA-01031: insufficient privileges
但不幸的是我没有“本地用户和组”部分我认为它只在 Windows NT 或服务器上
还有一个 Internet 上的答案建议在系统注册表中添加 "NLS_LANG" 并为 Arabic Unicode 分配值 AR8MSWIN1256(实际上有不同的值)
不幸的是我遇到了另一个问题
ORA-12505, TNS:listener does not currently know of SID given in connect descriptor
我遵循了这个答案,但它没有连接到我的数据库
但它一直给我同样的问题
所以我将我创建的注册表项 “NLS_LANG” 重命名为不同的名称,这是我唯一真正更改的内容,以恢复所有内容并且数据库再次运行
所以我的问题是:
Insert
和 Select
阿拉伯语值中的数据? (不知道是Oracle还是Java还是SQLPLUS哪里有问题!)更新 1:我的 Java 代码:
** OracleDBConnect2 类:**
包 com.oracle.testconnect;
导入java.io.BufferedReader;导入java.io.文件;导入 java.io.FileOutputStream;导入 java.io.InputStreamReader;导入 java.io.PrintWriter;导入 java.sql.Connection;导入 java.sql.DriverManager;导入 java.sql.ResultSet;导入 java.sql.Statement;导入 java.text.SimpleDateFormat;导入 java.util.ArrayList;导入 java.util.Calendar;导入java.util.Date;导入 java.util.HashMap;导入 java.util.Map;
导入 org.json.JSONArray;导入 org.json.JSONObject;
公共(public)类 OracleDBConnect2 { static PrintWriter logPrintWriter;
public static void main(String args[]) {
System.setProperty("file.encoding", "UTF-8");
JSONObject jsonObj = new JSONObject();
JSONArray jsonArray = new JSONArray(); // getting current datetime
try {
// create the connection object
Connection dbConnection = DriverManager
.getConnection(
"jdbc:oracle:thin:@url:port:DBName",
"username", "password");
// create the statement object
Statement sqlStatement = dbConnection.createStatement();
// execute query
String query = "select * from employee";
ResultSet results = sqlStatement.executeQuery(query);
// Convert result to json array
jsonArray = Convertor.convertToJSON(results);
System.out.println("jsonArray " + jsonArray.toString());
// Add JSON Array results to employee JSON Object
jsonObj.put("employees", jsonArray);
// Getting the output stream of the file for writing
File file = new File(Constants.JSON_FILE_PATH);
FileOutputStream fileOutputStream = new FileOutputStream(file);
PrintWriter printWriter = new PrintWriter(fileOutputStream);
if (!file.exists()) {
file.mkdirs();
file.createNewFile();
}
// Writing the user input to the file
printWriter.write(jsonObj.toString());
printWriter.flush();
fileOutputStream.close();
printWriter.close();
// close the connection object
dbConnection.close();
} catch (Exception e) {
System.out.println(e);
}
}
** 转换器类:**
公共(public)类转换器{
public static JSONArray convertToJSON(ResultSet resultSet) throws Exception {
JSONArray jsonArray = new JSONArray();
while (resultSet.next()) {
int total_rows = resultSet.getMetaData().getColumnCount();
JSONObject obj = new JSONObject();
for (int i = 0; i < total_rows; i++) {
obj.put(resultSet.getMetaData().getColumnLabel(i + 1).toLowerCase(), resultSet.getObject(i + 1));
}
jsonArray.put(obj);
System.out.println(resultSet.getString(1));
}
return jsonArray;
}
更新二:修改cmd的代码页
正如@plirkee 和@Vahadin 所建议的我已将 CMD 上的代码页更改为阿拉伯代码我还创建了一个名为“عربي”的空白文件,当我测试 ls 命令时它显示这样的名称 ''$'\330\271\330\261\330\250\331\212'
当我在 sqlplus 上尝试 select 语句时,我得到的阿拉伯值是 ????
我知道 cmd 有可能不支持阿拉伯语,但 oracle 的结果(如果配置没有问题)不应显示为 ?????而应该将其显示为我在 cmd 中创建的文件名
检查这是一个截图:
C:\Users\ahmed\Documents>chcp 20420
Active code page: 20420
C:\Users\ahmed\Documents>ls
'Custom Office Templates' 'My Videos'
FeedbackHub desktop.ini
'HP ePrint' hp.applications.package.appdata
'My Music' hp.system.package.metadata
'My Pictures' ''$'\330\271\330\261\330\250\331\212'
C:\Users\ahmed\Documents>chcp 28596
Active code page: 28596
C:\Users\ahmed\Documents>ls
'Custom Office Templates' 'My Videos'
FeedbackHub desktop.ini
'HP ePrint' hp.applications.package.appdata
'My Music' hp.system.package.metadata
'My Pictures' ''$'\330\271\330\261\330\250\331\212'
C:\Users\ahmed\Documents>sqlplus
SQL*Plus: Release 12.2.0.1.0 Production on Sat Dec 23 13:33:54 2017
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Enter user-name: system
Enter password:
Last Successful login time: Sat Dec 23 2017 13:27:42 +03:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> select * from employee
2 ;
FNAME LNAME PHONE AMOUNT
---------- ---------- ------------ ----------
???? Saleh 966000000000 30000
Saleh Salem 966000000000 40000
Hasan Damis 966000000000 25000
Ahmad ????? 966000000000 25000
Abbas Motwali 966000000000 20000
SQL>
最佳答案
首先 ALTER DATABASE CHARACTER SET ...
从 Oracle 10g 开始不再支持。你不应该使用它,你可能会破坏你的数据库。遵循 Oracle 的官方指南:Character Set Migration或使用 DMU - Database Migration Assistant for Unicode
NLS_LANG
的格式是“language_territory.charset”。 AR8MSWIN1256
不起作用,使用带点的.AR8MSWIN1256
(每个组件都是可选的,因此您可以跳过语言和地区)
SQLplus 从命令行继承编码。如果您使用 chcp 28596
,这意味着 ISO 8859-6
(参见 Code Page Identifiers),那么您的 NLS_LANG
值中的字符集必须是 .AR8ISO8859P6
(参见 Character Sets)
如果您喜欢使用 NLS_LANG=.AR8MSWIN1256
,那么您必须在启动 sqlplus 之前运行 chcp 1256
。
或者,如果您更喜欢使用 UTF-8,请像这样运行它:
c:\> chcp 65001
c:\> set NLS_LANG=.AL32UTF8
c:\> sqlplus ...
请注意,环境变量(即 set NLS_LANG=.AL32UTF8
)优先于注册表设置。
确保您在 cmd.exe
中使用的字体支持阿拉伯字符。您可以使用此页面进行测试:https://www.fileformat.info/info/unicode/font/fontlist.htm
同时检查这个答案:OdbcConnection returning Chinese Characters as "?"
关于Java我帮不了你,我不熟悉Java/JDBC。请记住,Java 不使用 NLS_LANG
设置,请参阅 Database JDBC Developer's Guide - Globalization Support
关于java - 在 Oracle 12c 上插入/检索阿拉伯语数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47950996/
#include using namespace std; class C{ private: int value; public: C(){ value = 0;
这个问题已经有答案了: What is the difference between char a[] = ?string?; and char *p = ?string?;? (8 个回答) 已关闭
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 7 年前。 此帖子已于 8 个月
除了调试之外,是否有任何针对 c、c++ 或 c# 的测试工具,其工作原理类似于将独立函数复制粘贴到某个文本框,然后在其他文本框中输入参数? 最佳答案 也许您会考虑单元测试。我推荐你谷歌测试和谷歌模拟
我想在第二台显示器中移动一个窗口 (HWND)。问题是我尝试了很多方法,例如将分辨率加倍或输入负值,但它永远无法将窗口放在我的第二台显示器上。 关于如何在 C/C++/c# 中执行此操作的任何线索 最
我正在寻找 C/C++/C## 中不同类型 DES 的现有实现。我的运行平台是Windows XP/Vista/7。 我正在尝试编写一个 C# 程序,它将使用 DES 算法进行加密和解密。我需要一些实
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
有没有办法强制将另一个 窗口置于顶部? 不是应用程序的窗口,而是另一个已经在系统上运行的窗口。 (Windows, C/C++/C#) 最佳答案 SetWindowPos(that_window_ha
假设您可以在 C/C++ 或 Csharp 之间做出选择,并且您打算在 Windows 和 Linux 服务器上运行同一服务器的多个实例,那么构建套接字服务器应用程序的最明智选择是什么? 最佳答案 如
你们能告诉我它们之间的区别吗? 顺便问一下,有什么叫C++库或C库的吗? 最佳答案 C++ 标准库 和 C 标准库 是 C++ 和 C 标准定义的库,提供给 C++ 和 C 程序使用。那是那些词的共同
下面的测试代码,我将输出信息放在注释中。我使用的是 gcc 4.8.5 和 Centos 7.2。 #include #include class C { public:
很难说出这里问的是什么。这个问题是含糊的、模糊的、不完整的、过于宽泛的或修辞性的,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开它,visit the help center 。 已关
我的客户将使用名为 annoucement 的结构/类与客户通信。我想我会用 C++ 编写服务器。会有很多不同的类继承annoucement。我的问题是通过网络将这些类发送给客户端 我想也许我应该使用
我在 C# 中有以下函数: public Matrix ConcatDescriptors(IList> descriptors) { int cols = descriptors[0].Co
我有一个项目要编写一个函数来对某些数据执行某些操作。我可以用 C/C++ 编写代码,但我不想与雇主共享该函数的代码。相反,我只想让他有权在他自己的代码中调用该函数。是否可以?我想到了这两种方法 - 在
我使用的是编写糟糕的第 3 方 (C/C++) Api。我从托管代码(C++/CLI)中使用它。有时会出现“访问冲突错误”。这使整个应用程序崩溃。我知道我无法处理这些错误[如果指针访问非法内存位置等,
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
已关闭。此问题不符合Stack Overflow guidelines 。目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,因为
我有一些 C 代码,将使用 P/Invoke 从 C# 调用。我正在尝试为这个 C 函数定义一个 C# 等效项。 SomeData* DoSomething(); struct SomeData {
这个问题已经有答案了: Why are these constructs using pre and post-increment undefined behavior? (14 个回答) 已关闭 6
我是一名优秀的程序员,十分优秀!