mysql数据库保存中文乱码解决参考方案
?//數據庫用戶名 ?
??? private static final String USERNAME = "root"; ?
??? //數據庫密碼 ?
??? private static final String PASSWORD = "root"; ?
??? //驅動信息? ?
??? private static final String DRIVER = "com.mysql.jdbc.Driver"; ?
??? //數據庫地址 ?
??? //private static final String URL = "jdbc:mysql://127.0.0.1:3306/boss";
??? public static final String url2 = "jdbc:mysql://localhost/pecope" + "?user=" + USERNAME + "&password=" + PASSWORD + "&useUnicode=true&characterEncoding=GBK";
??? private Connection connection; ?
??? private PreparedStatement pstmt; ?
??? private ResultSet resultSet; ?
??? public DBUtil() { ?
??????? // TODO Auto-generated constructor stub ?
??????? try{ ?
??????????? Class.forName(DRIVER);
??????????? connection=getConnection();
??????????? System.out.println("數據庫連接成功!"); ?
?
??????? }catch(Exception e){ ?
?
??????? } ?
??? }
轉載于:https://www.cnblogs.com/super-admin/p/5427144.html
總結
以上是生活随笔為你收集整理的mysql数据库保存中文乱码解决参考方案的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ASP.NET MVC 的一个配置节点
- 下一篇: 最全的MySQL基础【燕十八传世】