3

Arabic data is converting into ???? when java program queries xml payload from Oracle Table using Select statement

I have written a JDBC program to query xml type payload from Oracle table using Select statement. Few XML elements in the payload contains like FirstName, LastName etc. contains Arabic Characters. When i run my program, Select query returning the xml payload but the elements which having arabic characters are converting into ????. I am not sure why it is happening like this. is any one have solution for this problem?

Thanks in Advance.

Venkat
  • 33
  • 2
  • Hi Venkat, welcome to Stack Overflow. Could you kindly show what you have tried, some code or preview of what you are trying to achieve? That will help your question to be more answerable :). – ksugiarto Sep 09 '19 at 16:28
  • I assume you are using Oracle's JDBC driver. Have you also added `orai18n.jar` to your CLASSPATH ? – Abra Sep 09 '19 at 18:49

1 Answers1

2

I experienced this problem with java and mysql on eclipse the solution was From eclipse click right on your project and choose properties and choose utf-8 like this photo

enter image description here

Then from the database chose base encoding and utf-8 tables.

Finally, all database queries must be utf-8 encoded like this

String url = "jdbc:mysql://host/database?useUnicode=true&characterEncoding=utf8";
MC Emperor
  • 22,334
  • 15
  • 80
  • 130
Wassim Al Ahmad
  • 1,102
  • 2
  • 7
  • 23
  • Hi Wassim, The Eclipse option works as you mentioned. Thank you. – Venkat Sep 10 '19 at 01:20
  • 1
    Hi Wassim, as you mentioned url for MySQL database with userUnicode & Charcterencode, is there a way to use for Oracle Database? My URL: String url = "jdbc:oracle:thin:@hostname:xxxx:schemaname?useUnicode=true&characterEncoding=utf8"; Error: java.sql.SQLException: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor – Venkat Sep 10 '19 at 01:22
  • 1
    hi Venkat What version of Oracle are you using Such as 10g, 12g and also Oracle Express Edition – Wassim Al Ahmad Sep 10 '19 at 06:49
  • Dear Mr vekat Oracle and MySQL databases rely on SQL Everything you need is here in the Oracle Coding Contact Instructions https://docs.oracle.com/cd/B19306_01/server.102/b14225/ch7progrunicode.htm#i1006858 – Wassim Al Ahmad Sep 10 '19 at 07:19
  • 1
    You can also view the Arabic version of Oracle in this link https://mycodee.wordpress.com/2011/04/08/%D8%AF%D8%B9%D9%85-%D8%A7%D9%84%D9%84%D8%BA%D8%A9-%D8%A7%D9%84%D8%B9%D8%B1%D8%A8%D9%8A%D8%A9-%D9%81%D9%8A-%D8%A3%D9%88%D8%B1%D9%83%D9%84-xe/ – Wassim Al Ahmad Sep 10 '19 at 07:19
  • Finally, for the error that appeared with you try removing the (@) from your url has been the same error here in the stackOverFlow community from the following link https://stackoverflow.com/questions/18192521/ora-12505-tnslistener-does-not-currently-know-of-sid-given-in-connect-descript – Wassim Al Ahmad Sep 10 '19 at 07:20
  • To see the current encoding in the default db is utf-16 Execute this query: SELECT value$ FROM sys.props$ WHERE name = 'NLS_CHARACTERSET' ; I wish you success – Wassim Al Ahmad Sep 10 '19 at 07:24