Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

MySQL problem

 
Paul Cullen
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a application using a MySql database. The application retrieves information and prints it out. That bit is all working. But the problem I have when I print out the information e.g. dith m� I get dith m,.When I query the table the information comes out correct its only when the data is retrieved do I have problem..If any would could help it would be great.
 
Scott Selikoff
author
Saloon Keeper
Posts: 4010
18
Eclipse IDE Flex Google Web Toolkit
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try changing your output stream format from UTF8 to UTF16. It sounds like an encoding problem to me.
 
Paul Cullen
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply how would i introduce utf 8 encoding.
The part of the code that retrieves and outputs the data is below.


[ September 22, 2007: Message edited by: Ben Souther ]
 
Tarun Yadav
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think he meant change the charset for your response output stream: http://72.5.124.55/javaee/5/docs/api/javax/servlet/ServletResponse.html#setCharacterEncoding(java.lang.String)

You could also use setContentType() with the charset, as mentioned in the docs ( same link as above )
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to our servlet forum since this is about content types.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Jeanne Boyarsky:
Moving to our servlet forum since this is about content types.


I do not see the original poster saying anything about servlet .
Nor this question is related to servlets.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the encoding the database is currently on. Try to write with that encoding. Can you please provide some information on what technology you are using. For example Servlet -> JDBC -> DB and servlet redirects to JSP
 
Paul Cullen
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Eclipse.My program is a stand alone java swing front end using a MySQL database.I have set the encoding in MySQLI have queried the database with a statement from the MySQL server.This produces the correct output. But when I send it to the front end to display fron the database. It prints out "bheadh s," instead of "bheadh s�".
Here is the part of the code that retrieves an d prints it out.
public void verbSearch()
{
// connect to database books and query database
try
{
Class.forName( JDBC_DRIVER ); // load database driver class

// specify properties of JdbcRowSet
JdbcRowSet rowSet = new JdbcRowSetImpl();
rowSet.setUrl( DATABASE_URL ); // set database URL

rowSet.setCommand( "SELECT positive FROM verbTable4 " +
"WHERE word = '" + verbList.getSelectedItem().toString()+ "'" ); // set query
rowSet.execute(); // execute query

// process query results
ResultSetMetaData metaData = rowSet.getMetaData();
int numberOfColumns = metaData.getColumnCount();
//System.out.println( "Authors Table of Books Database:" );

// display each row
while ( rowSet.next() )
{
for ( int i = 1; i <= numberOfColumns; i++ )
{


area.append( "\n"+ rowSet.getString( i ) + "\t");
}
System.out.println();
} // end while
} // end try
catch ( SQLException sqlException )
{
sqlException.printStackTrace();
System.exit( 1 );
} // end catch
catch ( ClassNotFoundException classNotFound )
{
classNotFound.printStackTrace();
System.exit( 1 );
} // end catch
} // end constructor
 
sudhir nim
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try changing character encoding for eclipse workspace.

Goto windows>preferences>general>workspace.
change the text encoding to UTF-16 from default.
 
Paul Cullen
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.I tried this and got my code put in japenese.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic