日期:2014-05-20 浏览次数:20828 次
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.printStackTrace(); } } }