Jsp - Jconnector - MySql : Problem with danish characters

Posted on 2003-03-20
Medium Priority
Last Modified: 2008-02-01
What a mess!

I am building a web application using JSP connected to a MySQL Database via Jconnector.

My problem with the characters are threefold:

At the MySQL prompt I can use the danish letters "æ" and "å", but not "ø" - it is display like an "o".

When I write (for testing purposes) to the J2EE-Console the "æ" becomes a "'", the "å" is a strange looking spot and the "ø" is again "o".

When I write the characters to a JSP page the browser displays both "æ" and "å" as "?" and again the "ø" as "o".

I need the charaters to be THE SAME AT ALL THREE LEVELS.

Any experts know how?
Question by:NicolaiKrog
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Author Comment

ID: 8177670
OH NO!!!

I can now see that the danish characters are not displayed correctly either here at EE !!!!


Still need help!

Author Comment

ID: 8177682
Please ignore the letter-examples, I did not type "f", "e" and "x". I typed the the danish characters, that apparently does not work here either.  
LVL 14

Expert Comment

ID: 8178326
I would suggest you try use utf-8 encoding for web:

1. in every jsp page, include this
<%@ page contentType="text/html; charset=UTF-8" %>
<%request.setCharacterEncoding( "UTF-8" );%>

2. in every html page you need this line in your html <head>:

3. when store into database always use preparedStatement
PrepareStatement ps = conn.prepareStatement( "insert into table1( field1 ) value ( ? )" );
ps.setString( 1, data );
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 14

Accepted Solution

kennethxu earned 1500 total points
ID: 8178493
try out this example:

<%@ page import="java.sql.*" %>
<%@ page contentType="text/html; charset=UTF-8" %>
<%request.setCharacterEncoding( "UTF-8" );%>

<form method="post">
<input type="text" name="data">
<input type="submit">
<% String data = request.getParameter( "data" ); %>
<p>Data submitted: <%=data%>
<p>Data from database:
  // ******* create your database connection here
  Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
  Connection conn = DriverManager.getConnection( "jdbc:odbc:test", "admin", "" );
  if( data != null ) {
     PreparedStatement ps = conn.prepareStatement( "insert into table1( field1 ) values ( ? )" );
     ps.setString( 1, data );
  Statement stat = conn.createStatement();
  ResultSet rs = stat.executeQuery( "select field1 from table1" );
  while( rs.next() ) {
    String fromDB = rs.getString( 1 );

Author Comment

ID: 8191848
Thanks for the work Kenneth!

I have now solved the problem, - a combination of your suggestions, but most importantly I have realized that when new data are inserted into the database, it should always be done via JSP if you want to retreive them via JSP!

Ie. data inserted from the prompt != data retreived from jsp!

But thanks for your time , - you get the points!

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a fine trick which I've found useful many times, when you just don't want to accidentally run a batch script or the commands needs administrator rights.
The well known Cerber ransomware continues to spread this summer through spear phishing email campaigns targeting enterprises. Learn how it easily bypasses traditional defenses - and what you can do to protect your data.
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question