求助:JAVA查询MYSQL语句有中文返回为空
MYSQL配置默认字符集是utf8,MyEclipse6.0设置默认字符集是utf8,数据库表中含中文。
Java code:
public class TestPolm{
public static void main(String args[]){
try {
Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e) {
System.out.println("Load driver failed��");
}
Connection con = null;
PreparedStatement ps=null;
ResultSet rs=null;
try {
con = (Connection) DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8", "root", "1111");
String sql = null;
try {
sql = new String("select * from ic_content_0002 where Title like '%窗口%'".getBytes(),"UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
System.out.println(rs.getFetchSize());
while(rs.next()){
StringBuffer sb = new StringBuffer();
sb.append(rs.getString("Id"));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.
相关问答:
我的开发的平台是Myeclipes6.0 + tomcat5.x + mysql
我所有的编码方式都是用的UTF-8
我只用了Strtus框架
在一个form中如下用的是post的提交方式:
<form class="form" action=&quo ......
import java.io.*;
class FileTest
{
public static void main(String [] args) throws Exception
{
File fDir=new File(File.separator);
String strFile="java源代码测试"+File.separato ......
我的java applet 嵌入html后无法显示,而用appletviewer显示正常为什么,还有就是用html converter转化后可以显示,为什么?请大侠赐教!
HTML code:
<HTML>
<HEAD>
<TITLE>TEST.HTML< ......