首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

四种惯用数据库的驱动程序包名字及连接字符串

2012-08-27 
四种常用数据库的驱动程序包名字及连接字符串??????? }??? }}驱动方式package com.ld.bakimport java.sql

四种常用数据库的驱动程序包名字及连接字符串
??????? }
??? }
}

驱动方式
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();
??????? }
??? }

}

热点排行