• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDBC and Arabic character

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI All,

I am trying retrieve arabic characters from oracle10g database using java and write it to txt file.
The database characterset is ARABIC_UNITED ARAB EMIRATES.AR8ISO8859P6.
In my registry entry I have NLS_LANG value as ARABIC_UNITED ARAB EMIRATES.AR8ISO8859P6.

The txt file generated by the java code is having ? marks and few arabic characters.

The arabic characters in the database is all correct. I am able to see the proper arabic characters by copy pasting from TOAD screen to text editor with windows 1256 encoding.

I have classes12.jar,ojdbc14.jar,orai18n.jar,nls_charset12.jar in classpath.

I tried oci and thin driver both gives same result.

Can anyone help to figure out if I am doing anything wrong? Is there any special procedure to handle the arabic characters?
Below is the java code?


import oracle.jdbc.*;
import oracle.sql.*;
import java.io.*;
import java.sql.*;

public class DOC1Test
{
//private static final Charset ISO_8859_1 = Charset.forName("ISO-8859-6");
public DOC1Test()
{

}

public void javajdbc()
{
try
{

DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
OracleConnection con = (OracleConnection)DriverManager.getConnection("jdbc:oracle:thin:@172.24.72.12:1521:ORCL4","DEV_EAI", "eai");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select subject from event_queue where id='3'");

while (rs.next())
{
BufferedWriter out = new BufferedWriter (new OutputStreamWriter(new FileOutputStream("E:\\codepage\\arabic-out.txt"), "Cp1256"));
//out.write(encode(rs.getString("subject"),"ISO-8859-6", "windows-1256"));
String finalstr = new String(rs.getString("subject").getBytes(),"Cp1256");
out.write(finalstr);
out.flush();
}

}catch(Exception e)
{
e.printStackTrace();
}
}

public static void main(String[] args)
{
DOC1Test doctest = new DOC1Test();
doctest.javajdbc();
}
}
 
reply
    Bookmark Topic Watch Topic
  • New Topic