• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MySQL problem

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Ranch Hand
Posts: 134
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 )
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to our servlet forum since this is about content types.
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 212
Eclipse IDE Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply.I tried this and got my code put in japenese.
 
Grow your own food... or this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic