I am making a Library Management System, I am trying to add arabic support in my project but I am facing difficulties as follows,
when inserting data in SQL through Query i.e
Insert into book_info values(25, N'جاوا', N'Author',N'Publisher',2014,N'Subject',50,N'Language','Latest',5)
The List of Columns in book_info is as follows- Book ID(int)
- Book Title(NVarchar(50))
- Author(NVarchar(50))
- Publisher(NVarchar(50))
- Publish Year(int)
- Subject(NVarchar(50))
- Price(int)
- Language(NVarchar(50))
- Edition(NVarchar(50))
- Part(int)
Therefore when I execute this query through my Project,
SQL Management Studio
Shows some Encoded Characters like'مجتبیٰ'
in place of Arabic Characters, and not only inSQL Management Studio
but also when Selecting data in project. Note: these values in query are taken fromtextfield
through.getText()
functionWhat if we just skip the first problem by executing the query in
SQL Management Studio
, by doing this the first problem is temporarily resolved asSQL Management Studio
is showing arabic characters when selecting the data but again when we select it from our software and show it inTextfield
by Getting data fromResultSet
like "TextF.setText(ResultS.getNString())
" it shows "??????
" in the text field in place of Arabic Characters.
Your database definition, query, and SQL instance is fine. The issue you are having is with reading the string from the database into java.
I think Java is trying to read your nvarchar text as ASCII characters, when they are actually in Unicode. The result is garbled looking text. I think when you read the text from the database, you'll need to ensure you're reading as Unicode.
If you can post your code, I could probably pinpoint what is causing you issues.