MySQL Forums
Forum List  »  Connector/JDBC and Java

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
March 28, 2012 06:59AM


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.