我的问题是下一个代码有什么问题?我试图用j2ee从数据库中读取一些unicode,并将一些字符作为着名的问号返回。Java Unicode问题
尝试 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());
}
现在我已经试过这个代码与j2Se以及它的作品。那么它是j2EE还是我错过了我的代码?
感谢
我使用一个集成的Tomcat6.0服务器来使用NetBeans。对于我的数据库我使用EasyPHP 3.0。也许这有助于 –