Skip navigation links

MySQL Forums :: Connector/JDBC and Java :: Unable to retrieve unicode data


Advanced Search

Unable to retrieve unicode data
Posted by: Leonard Fernandes ()
Date: March 28, 2012 06:59AM

Hello,

Please help me with this one. I was able to successfully add unicode data to a table but am unable to retrieve it. The resultset is empty although the same query generates a valid resultset through the query browser. Here is the code:


try {

keyword = new String(keyword.getBytes("ISO-8859-1"), "UTF-8");

} catch (UnsupportedEncodingException usee){

keyword = "'";
}

keyword = Utilities.replaceQuotes(keyword);

System.out.println(CLASS_NAME + " : " + METHOD_NAME + "keyword :" + keyword);

String sequel = "SELECT book_name, book_isbn, " +
"FROM book_resource_user_view ";
sequel += "WHERE MATCH(book_name, book_isbn, bookauthor1, bookauthor2, bookauthor3) AGAINST ('"+keyword+"') ";


Connection objConn = null;
Statement state = null;
ResultSet results = null;
ConnectionPool connectionPool = null;

try {

connectionPool = new ConnectionPool(10, 50, true);
objConn = connectionPool.getConnection();

System.out.println(CLASS_NAME + " : " + METHOD_NAME + "sequel :" + sequel);

state = objConn.createStatement();

results = state.executeQuery(sequel);

connectionPool.free(objConn);

String bookName = "";
String bookISBN = "";

while (results.next()) {

item = new CartItemDetail();

bookName = results.getString("book_name");


item.setBookName(bookName);

bookISBN = results.getString("book_isbn");
item.setBookISBN(bookISBN);

}

} catch (SQLException sqle) {

System.out.println("SQL Exception encountered :" + CLASS_NAME
+ " : " + METHOD_NAME + ":" + sqle.getMessage());
objConn = null;

} finally {

try {

results.close();
state.close();
objConn.close();
connectionPool.closeAllConnections();
connectionPool = null;

} catch (SQLException sqle) {
}
}


Thank you,

Leonard

Options: ReplyQuote


Subject Written By Posted
Unable to retrieve unicode data Leonard Fernandes 03/28/2012 06:59AM
Re: Unable to retrieve unicode data Peter Brawley 03/28/2012 02:04PM
Re: Unable to retrieve unicode data Leonard Fernandes 03/28/2012 09:55PM
Re: Unable to retrieve unicode data Rick James 03/29/2012 10:14PM
Re: Unable to retrieve unicode data Leonard Fernandes 04/01/2012 12:52AM
Re: Unable to retrieve unicode data Leonard Fernandes 04/25/2012 11:59PM
Re: Unable to retrieve unicode data Leonard Fernandes 04/26/2012 12:00AM
Re: Unable to retrieve unicode data Mark Matthews 04/26/2012 01:37PM
Re: Unable to retrieve unicode data Rick James 04/26/2012 08:39PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.