scala+Lift框架,查询mysql数据库,数据库编码是utf-8,查出数据是问号(???),哪位大侠知道解决方法
发布网友
发布时间:2022-04-09 01:58
我来回答
共3个回答
懂视网
时间:2022-04-09 06:19
"dbtable" -> "crm_order")).load()
val tableDF = sqlContext.jdbc("jdbc:mysql://mysql_hostname:mysql_port/testDF?user=your_username&password=your_password", "user")
//查询mySql数据库
val tableDF = sqlContext.jdbc("jdbc:mysql://10.1.2.190:8066/mq_sale_disc?user=kr.user&password=user@85263382", "tmp_enterprise")
注意:execute、executeUpdate、executeQuery三者区别
查询用executeQuery
插入、更新、删除用executeUpdate
scala链接mysql
标签:
热心网友
时间:2022-04-09 03:27
确定执行以下命令后结果和以下所示相同
mysql> show variables like "%character%";show variables like "%collation%";
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)
+----------------------+-----------------+
| Variable_name | Value |
+----------------------+-----------------+
| collation_connection | utf8_unicode_ci |
| collation_database | utf8_unicode_ci |
| collation_server | utf8_unicode_ci |
+----------------------+-----------------+
热心网友
时间:2022-04-09 04:45
检查mysql字符集是不是对,如果字符集本身就是乱的,那没法子。改成utf8吧。
检查链接字符串是不是有characterEncoding=utf8这样的属性