1)把涉及数据表的自增字段的自增选项去掉,保存一下
2)重新将这个字段设置为自增字段
4.SSM mybatis 控制台不显示sql:
方法1:
(1)依然新建“mybatis-config.xml”配置文件,如下:
但是如果是Spring整合MyBatis的情况下,我们通常会写一个spring-mybatis.xml的配置文件
此时,如果是这样的写法,这个配置文件暂时不会生效,因为没有在这个spring-mybatis.xml注册,Spring就不会扫描这个配置文件
此时,修改spring-mybatis.xml中id为:sqlSessionFactory的bean,修改如下写法:
方法2:
使用slf4j输出
因此要先添加slf4j的依赖
org.slf4j
slf4j-log4j12
1.7.6
log4j配置文件:
log4j.logger.com.ibatis=DEBUG
log4j.logger.com.ibatis.common.jdbc.SimpleDataSource=DEBUG
log4j.logger.com.ibatis.common.jdbc.ScriptRunner=DEBUG
log4j.logger.com.ibatis.sqlmap.engine.impl.SqlMapClientDelegate=DEBUG
log4j.logger.java.sql.Connection=DEBUG
log4j.logger.java.sql.Statement=DEBUG
log4j.logger.java.sql.PreparedStatement=DEBUG
方法3.
log4j2
配置如下
引入Maven依赖
org.apache.logging.log4j
log4j-core
2.8.2
org.apache.logging.log4j
log4j-api
2.8.2
org.apache.logging.log4j
log4j-web
2.8.2
org.apache.logging.log4j
log4j-slf4j-impl
2.0.2
5.mybatis Cause: org.xml.sax.SAXParseException; lineNumber: 39; columnNumber: 97; 元素内容必须由格式正确的字符数据或标记组成。
第一种方法:
用了转义字符把>和
SELECT * FROM test WHERE 1 = 1 AND start_date <= CURRENT_DATE AND end_date >= CURRENT_DATE
附:XML转义字符
<
> > 大于号
& & 和
' ’ 单引号
" " 双引号
第二种方法:
因为这个是xml格式的,所以不允许出现类似“>”这样的字符,但是都可以使用符号进行说明,将此类符号不进行解析
你的可以写成这个:
mapper文件示例代码
6.数据库时区错误
java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
使用spring boot整合MySQL时一直报
java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone
报错信息
系统时区的错误
查看mysql时区
show VARIABLES like "%time_zone%"
解决方法:
1.在原来的参数“url”后面,拼上这个字符串:?serverTimezone=GMT%2B8,
如:jdbc:mysql://localhost:3306/test?serverTimezone=GMT%2B8
东八区的表示:
GMT%2B8,即GMT+8,北京时间东八区
Asia/Shangha,上海时间
2.设置mysql的时区
MySQL默认的时区是UTC时区
(1)永久的修改:修改mysql的配置文件,添加:default-time-zone='+08:00',重启mysql生效
(2)临时的修改:执行mysql命令 set global time_zone='+08:00',立即生效,重启mysql后失效
Navicat 需要重新断开连接再打开查询
1.环境
win7/8/8.1 x64,oracle 11g r2,jdk8 x64
2.问题
第一次启动Oracle SQL Developer的时候会让我们填写java.exe的路径,我在jdk安装目录下的bin中找到了java.exe,但是填写以后报如下错误:
WARNING: Could not find jvm.cfg! in 'D:\app\Administrator\product\11.2.0\dbhome_1\jdk\jre\lib\jvm.cfg'
3.原因
oracle 11g中安装的Oracle SQL Developer是32位的,而我们现在给他指定的java.exe却是64位的,所以会出现这种错误。
4.解决方法
1)从网上下载Oracle SQL Developer x64,然后替换原目录:D:\app\oracle\product\11.1.0\db_1\sqldeveloper下的32位的Oracle SQL Developer。这样重新启动Oracle SQL Developer 并制定java.exe的路径就可以了。
2)安装JDK6 x86,也就是32位的JDK,虽然我们的系统是64位的,但是也兼容32位的JDK。
上述两种方法均试过,都可以正常运行。
也可以修改 {ORACLE_HOME}\sqldeveloper\sqldeveloper\bin\sqldeveloper.conf 文件的 SetJavaHome,重新定向到 32位jdk。
8.net start mysql 发生系统错误2 系统找不到指定的文件
以管理员身份运行,在命令行输入cd+mySQL的bin目录的安装路径
C:\Windows\system32>cd C:\Program Files\MySQL\MySQL Server5.6\bin
C:\Program Files\MySQL\MySQL Server5.6\bin>mysqld --remove
Service successfully removed.
C:\Program Files\MySQL\MySQL Server5.6\bin>mysqld --install
Service successfully installed.
C:\Program Files\MySQL\MySQL Server5.6\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
9.navicat连接mysql报错1251解决方案 :client does not support...
今天下了个 MySQL8.0,发现Navicat连接不上,总是报错1251;
原因是MySQL8.0版本的加密方式和MySQL5.0的不一样,连接会报错。
试了很多种方法,终于找到一种可以实现的:
更改加密方式
1.先通过命令行进入mysql的root账户:
PS C:\Windows\system32> mysql -uroot -p
再输入root的密码:
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 8.0.11 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
2.更改加密方式:
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected (0.10 sec)
3.更改密码:该例子中 123为新密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';
Query OK, 0 rows affected (0.35 sec)
4.刷新:
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.28 sec)
// 如果报错ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'%':
则是远程访问权限不正确,先选择数据库,查看一下再更改:
mysql> use mysql;
Database changed
mysql> select user,host from user;
+------------------+-----------+
| user | host |
+------------------+-----------+
| mysql.infoschema | localhost |
| mysql.session | localhost |
| mysql.sys | localhost |
| root | localhost |
+------------------+-----------+
5 rows in set (0.00 sec)
10.'net’ 不是内部命令或外部命令,也不是可运行的程序或批处理文件
我的电脑-->属性-->高级-->环境变量 path的变量值新加: %SystemRoot%\system32
修改完成后,需要重新打开cmd命令行,否则不会生效的。