Hi there. My question would be what's wrong with the next code? I'm trying with j2ee to read some unicode from a database and some characters are returned as the famous question mark.
try { Class.forName("com.mysql.jdbc.Driver"); String connectionUrl = "jdbc:mysql://localhost/hortimart?" + "user=webservices&password=stipjeservers"; Connection con = DriverManager.getConnection(connectionUrl);
Statement stmt = null;
ResultSet rs = null;
String SQL = "SELECT FirstName,LastName FROM users";
stmt = con.createStatement();
rs = stmt.executeQuery(SQL);
while (rs.next())
{
byte[] firstNameBytes = rs.getBytes(1);
String FirstName =new String(firstNameBytes,"UTF-8");
byte [] lastNameBytes = rs.getBytes(2);
String LastName =new String(lastNameBytes,"UTF-8");
System.out.println(FirstName+" "+LastName);
}
}
catch (SQLException e)
{
System.out.println("SQL Exception: "+ e.toString());
}
catch (ClassNotFoundException cE)
{
System.out.println("Class Not Found Exception: "+ cE.toString());
}
Now i've tried this code with j2Se as well and it works. So is it j2EE or i missed something in my code?
Thanks