jdbc编程中用eclipse如何插入中文数据??

yhm2046 2012-03-31 10:42:54
public static void main(String[] args) throws ClassNotFoundException,
SQLException {
// 1.加载驱动
Class.forName("com.mysql.jdbc.Driver");
// 2.建立连接
Connection conn = DriverManager
.getConnection(
// 怎样插入中文??,在mysql中显示乱码捉鸡
"jdbc:mysql://localhost:3306/b1?useUnicode=true&characterEncoding=UTF-8",
"root", "toor");
// 创建Statement
Statement stm = conn.createStatement();
// 发送sql语句
String sql = "insert into t1 value(11,'奥巴马')";
...全文
48 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
computerclass 2012-03-31
  • 打赏
  • 举报
回复
你这个工程最好是utf-8的,数据库中最好也是

23,407

社区成员

发帖
与我相关
我的任务
社区描述
Java 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧