The first time to install and use mybatis, problems encountered are as follows:
Question 1: Unkonwn database ‘test’
I created a new test database in my own database, and the corresponding table name, the problem was solved. However, what I want to understand is: how to specify which database and which table to use in the XML configuration file, otherwise, this problem will appear.
Question 2: The server time zone value ‘appears in MySQL й ��� ʱ ‘is unrecognized record
Solution 1: modify the database time zone
set global time_ zone = ‘+8:00’; ## Modify the global time zone of Mysql to Beijing time, that is, the East 8 district where we are
in the database set time_ zone = ‘+8:00’; ## Modify the time zone of the current session
0 flush privileges; # Effective immediately
Solution 2: modify the value of driver and URL.
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Pay attention to this configuration header tag, don't make a mistake -->
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<environments default="bank">
<environment id="bank">
<!-- Using jdbc transaction management -->
<transactionManager type="JDBC" />
<!-- Database connection pooling -->
<dataSource type="POOLED">
<property name="driver" value="com.mysql.cj.jdbc.Driver" />
<property name="url"
value="jdbc:mysql://localhost:3306/test?characterEncoding=utf-8" />
<property name="username" value="root" />
<property name="password" value="123456" />
</dataSource>
</environment>
</environments>
<!-- This place configures the entity class sql mapping file -->
<mappers>
<mapper resource="pufaSpring\otherMybatis\UserMapper.xml"/>
</mappers>
</configuration>
Read More:
- Solve ERROR 1231 (42000): Variable’time_zone’ can’t
- [Solved] tidb-cdc Create Task Error: Unknown or incorrect time zone
- Using Mybatis to connect to the database error: Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver···
- Lock request time out period exceeded. (Microsoft SQL Server, Error: 1222)
- [Solved] The number of rows returned by the mybatis UPDATE statement is always 1 or useaffectedrows = true
- Cannot resolve classpath entry: e://jar/mysql-connector-java-5.1.17-bin mybatis error in reverse engineering
- Mysql + Mybatis Batch Update Datas Error: BadSqlGrammarException
- Can mybatis prevent SQL injection
- [Solved]ERROR 1067 (42000): Invalid default value for ‘end_time‘ Mysql
- [Solved] workbench ssl connection error ssl is required but the server
- How to Fix MySQL ERROR 1130 (HY000): Host ‘XXXX’ is not allowed to connect to this MySQL server
- host ‘‘ is not allowed to connect to this mysql server Connect MYSQL Error
- MYSQL Slave is not configured or failed to initialize properly. You must at least set –server-id
- MYSQL 5.7 Error Code: 1290. The MySQL server is running with the –secure-file-priv option so it..
- Remote connection to MySQL database error: is not allowed to connect to this MYSQL server solution
- Idea connect mysql error Server returns invalid timezone. Go to’Advanced’ tab and set’serverTimezone’ property
- Mybatis Add Datas error: ERROR: Field * doesn‘t have a default value
- [Solved] Error: ER_HOST_NOT_PRIVILEGED: Host ‘x.x.x.x‘ is not allowed to connect to this MySQL server
- Mybatis Error setting non null for parameter #15 with JdbcType null Could not set parameters for
- MySQL server has gone away Error [How to Solve]