四种常用数据库的驱动程序包名字及连接字符串
??????? }
??? }
}
驱动方式
package com.ld.bak;
import java.sql.*;
public class ChineseQuery {
??? public static void main(String[] args) {
??????? // TODO Auto-generated method stub
??????? try {
??????????? String url = "jdbc:mysql://localhost:3306/land?useUnicode=true&characterEncoding=GB2312";
??????????? Class.forName("com.mysql.jdbc.Driver");
??????????? Connection conn = DriverManager.getConnection(url, "root",
??????????????????? "6573251");
??????????? Statement stmt = conn.createStatement();
??????????? ResultSet rs = stmt
??????????????????? .executeQuery("SELECT * FROM tbnews WHERE News_Id = BINARY '1'");
??????????? while (rs.next()) {
??????????????? System.out.println(rs.getInt(1) + "\t" + rs.getString(5));
??????????? }
??????? } catch (Exception e) {
??????????? e.printStackTrace();
??????? }
??? }
}