Dear Friends,

I a working on a project where i have to let the user to type in other languages(hindi,tamil,kannada etc..) and i have to store into the database and retrive it back and show it to the client in the same language he has entered..I am using postgres 8.0 for storing the data. When i tried to store the data's its storing in database as "ल�ि�प�िप�" and displaying it in the same manner...Can any one help me how to fix this..Thanks in advance

i use the following code to store

english.jsp

<input type="button" name="but1" value="<%=session.getValue("main.Bok")%>" onClick="callSearch()">

function callSearch()
	{                                                                                                      
     var f = document.forms[0];//("myform");
	 var semiCol = ":";
     var Name = document.myForm.Name.value;
     var Company = document.myForm.Company.value;
	 var DOB = document.myForm.DOB.value;
	 var Age = document.myForm.Age.value;
	

		
	// 	parent.document.getElementById("Local").src="jdbcConnection.jsp?Name="+Name+"&Company="+Company+"&DOB="+DOB+"&Age="+Age;
        alert("Name = "+Name);
        window.location.href="./jdbcConnection.jsp?Name="+Name+"&Company="+Company+"&DOB="+DOB+"&Age="+Age;
}

jdbcConnection.jsp

<%
		request.setCharacterEncoding("UTF-8");
        String szName=request.getParameter("Name");
		System.out.println("Name = "+szName);
		String szCompany=request.getParameter("Company");
    System.out.println("Company = "+szCompany);
		String szDOB=request.getParameter("DOB");
		System.out.println("DOB = "+szDOB);
        String szAge=request.getParameter("Age");
		System.out.println("Age = "+szAge);

          try{
			Connection conn;
			String szUrl;
			 Class.forName("org.postgresql.Driver");
			 szUrl="jdbc:postgresql://localhost/jaiprakash";
			 System.out.println("Driver created");
			 conn = DriverManager.getConnection(szUrl,"postgres","password");
			 System.out.println("Connection created");
			 Statement sqlString1=conn.createStatement();
			 sqlString1.executeUpdate("INSERT INTO public.user values('"+szName+"','"+szCompany+"','"+szDOB+"','"+szAge+"')");
//sqlString1.executeUpdate("INSERT INTO public.user values('gfgfdg','gffdggf','gdfgdfg','gdfgdfg')");
			 System.out.println("Query executed....");
			 conn.close();
		}catch(Exception e){
		e.printStackTrace();
		}		

         %>

Regards,
Jayaprakash

Make sure your database/table is created with Unicode as the encoding. Refer the Postgresql forums/documentation for more details.

Also try getting the connection with the URL which also specifies the character set explicitly.

jdbc:postgresql://localhost:5432/testdb?charSet=YOUR-ENCODING-HERE

Thanks for the reply.. I have solved the Thread by changing the database version.. From 8.0 to 8.3(Supports UTF-8 encoding)

I have removed the function call search and changed the method

<form name="myForm" ID="Local" method="POST" action="jdbcConnection.jsp">

Now it is working fine...

This question has already been answered. Start a new discussion instead.