Home >Database >Mysql Tutorial >Java中连接数据库时汉字都变成问号问题(mysql)_MySQL

Java中连接数据库时汉字都变成问号问题(mysql)_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 13:11:362035browse


package Login;import java.sql.Connection;import java.sql.DriverManager;public class GetConn { public Connection conn=null; public Connection getConnection(){ try{ Class.forName("com.mysql.jdbc.Driver"); String url="jdbc:mysql://localhost:3306/select_courses" +"?useUnicode=true&characterEncoding=utf8"; //确定字符集 String user="root"; String passWord=""; conn=DriverManager.getConnection(url,user,passWord); if(conn!=null){ System.out.println("数据库链接成功"); } }catch(Exception e){ e.printStackTrace(); } return conn; }}


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn