jeudi 7 juillet 2011

How to ( The Solution ) of select and insert arabic on JSP / mysql (English virsion)


i suffered with this big problem , i google it  for many days , ther is no solution 
blieve mei found none solution  .
and i tryied find a solution  myself , and i did it finaly
so here is the solution and i have tested it for month ,plus i created a web site with this library and t work perfectly ,
the library have 2 functions 
enco(String arabic ) , and deco(String arabic)
the booth return  String
enco when you save a value into database , and decod for geting a value from database  , 
it's works with any database provider  , mysql , oracle ....
notice :
you need to writ this 2 lines on the first of every page you use on it the none latine in our case the arabic 
<%request.setCharacterEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");%>
how to use this library:
1:go to library fil into you application directory and add our library
2: then on you jsp/servlet page  import the library like this
<%@page import="imad.*" %>
3: the when you neead to insert a arabic line use the library like this 
String art=imadboy.enco(art2);
int t=Service.update("insert into table values( '"+art+"');  
art2 it's your arabic string 
and it's done :) the arabic string saved succesfuly 
4 : when u need to select from database use this 
RseultSet rs=Service.select("select from table where name='arabic'");
if(rs.next()){
String article = imadboy.deco(rs.getString(2));
}
5 : no more , this is how it's work :) now time to download the library and an exempl

Aucun commentaire:

Enregistrer un commentaire