• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

storing the Unicodes in the database

 
Sathish Ramadas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have some problem with Unicode datatype. I am storing the japanese charater in the Oracle 9i database. Taking input (japanese charater) from the browser and storing into the database. Ans also i retrieving back, the browser is showing the japanese charater properly.
I have doubt in storing the japanese character in the database, will it be stored like this format (万万万上与久 in the database. The thing use we are using some reporting tool Business Objects to genereate the report using the oracle as database. We are not sure about the tool is supporting the japanese charater properly or problem with unicode storage in the dataabse.

can you please help.
 
Natarajan Shankar
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Satish,
While storing tin Database I hope it will store as binary. So the problem might be in your program/ report tool which takes the input from the Database it might convert again to binary so you might get junk or the output what u havn't expected.

At the same time you can check passing value directly from UI to report possible, as it might give a hint.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Sathish" -

Welcome to the JavaRanch! We don't have many rules around the 'Ranch, but we do require your display name to follow the JavaRanch Naming Policy.
You can change it here.


Thanks! and welcome to the JavaRanch!
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the JDBC forum.
 
Sathish Ramadas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey...I write the unicode in an XML file . When i open the xml file in the browser it is showing the japanese character. so what's your opinion whether it is writing the unicode properly or not. Pls see my code. Also i have a doubt that we don't need to specify any format while storing the japanese character in the database.The database will take care of it right. The thing we need to store it in a proper datatype (NVARCHAR2 in oracle).



code Here...

<%@ page language="java" contentType="text/html; charset=Shift-JIS"%>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Shift-JIS">


<%
String XML_ROOT_TAG ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?<Sample>";
String XML_END_TAG = "</Sample>";

request.setCharacterEncoding("ISO-8859-1");
String inputValue = request.getParameter("Input");
String username = "bo6steps";
String password = "bo6steps";
String dbname = "CLXDEV";
String hostname = "njdbupora0-m";//"tkops1dsyb-v1";
String port = "2604";
Connection conn = null;
PreparedStatement ps= null;

String sql = "insert into template1(Id,JpName) values(?,?)";
String sql1 = "select * from template1";

try {
System.out.println("Creating Connection");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String connectionURL = "jdbc dbc:bo6steps";
// Attempt to connect to a driver.
conn = DriverManager.getConnection(connectionURL, username,
password);

System.out.println("got connection");
ps = conn.prepareStatement(sql);
ps.setString(1, "66");
ps.setString(2, inputValue);
int i=100;
ps.executeUpdate();

ps = conn.prepareStatement(sql1);
ResultSet rs = ps.executeQuery();
FileOutputStream outStream = new FileOutputStream ("dbDetails.xml");
String temp1=null;
String temp2 = null;
outStream.write(XML_ROOT_TAG.getBytes());
while(rs.next()){

temp2 = new String(rs.getString(2).getBytes("Shift-JIS"));
out.println(temp2);
out.println("................. ");
outStream.write(temp2.getBytes());
}
outStream.write(XML_END_TAG.getBytes());

}
catch (Exception e) {
e.printStackTrace();
}
finally {
try {
ps.close();
conn.close();
System.out.println("closed connection");
}
catch (Exception e) {
e.printStackTrace();
}

}


%>
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65126
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Sathish",

Nathan's request to change your display name was not a suggestion. Proper display names are required. Take a look at the JavaRanch Naming Policy and adjust your display name to match it prior to your next post.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

bear
Forum Bartender
 
Sathish Ramadas
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Updated the display name....

Can anyone please look at the code help to solve the problem. I dint get any reply....pls help me.

hey...I write the unicode in an XML file . When i open the xml file in the browser it is showing the japanese character. so what's your opinion whether it is writing the unicode properly or not. Pls see my code. Also i have a doubt that we don't need to specify any format while storing the japanese character in the database.The database will take care of it right. The thing we need to store it in a proper datatype (NVARCHAR2 in oracle).



code Here...

<%@ page language="java" contentType="text/html; charset=Shift-JIS"%>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=Shift-JIS">


<%
String XML_ROOT_TAG ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?<Sample>";
String XML_END_TAG = "</Sample>";

request.setCharacterEncoding("ISO-8859-1");
String inputValue = request.getParameter("Input");
String username = "bo6steps";
String password = "bo6steps";
String dbname = "CLXDEV";
String hostname = "njdbupora0-m";//"tkops1dsyb-v1";
String port = "2604";
Connection conn = null;
PreparedStatement ps= null;

String sql = "insert into template1(Id,JpName) values(?,?)";
String sql1 = "select * from template1";

try {
System.out.println("Creating Connection");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String connectionURL = "jdbc dbc:bo6steps";
// Attempt to connect to a driver.
conn = DriverManager.getConnection(connectionURL, username,
password);

System.out.println("got connection");
ps = conn.prepareStatement(sql);
ps.setString(1, "66");
ps.setString(2, inputValue);
int i=100;
ps.executeUpdate();

ps = conn.prepareStatement(sql1);
ResultSet rs = ps.executeQuery();
FileOutputStream outStream = new FileOutputStream ("dbDetails.xml");
String temp1=null;
String temp2 = null;
outStream.write(XML_ROOT_TAG.getBytes());
while(rs.next()){

temp2 = new String(rs.getString(2).getBytes("Shift-JIS"));
out.println(temp2);
out.println("................. ");
outStream.write(temp2.getBytes());
}
outStream.write(XML_END_TAG.getBytes());

}
catch (Exception e) {
e.printStackTrace();
}
finally {
try {
ps.close();
conn.close();
System.out.println("closed connection");
}
catch (Exception e) {
e.printStackTrace();
}

}


%> Can anyone please look at the code help to solve the problem. I dint get any reply....pls help me.
 
Hima Mangal
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sathish,

In case you have managed to figure out the solution, can you please let us know about it too?

Thanks
~H
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic