Home > Back-end >  Mybatis error connecting to the database
Mybatis error connecting to the database

Time:09-19

Use Mybatis first connect to the database error: FATAL [main] main - getAssociatedStylesheets failed
The source code download from: https://how2j.cn/k/mybatis/mybatis-tutorial/1087.html#nowhere
Ask god to help look at what's situation,

 
& lt; ? The XML version="1.0" encoding="utf-8"?>
PUBLIC "-//mybatis.org//DTD Config/3.0/EN"
"Http://mybatis.org/dtd/mybatis-3-config.dtd" & gt;











Use Mybatis first connect to the database error: FATAL [main] main - getAssociatedStylesheets failed

The source code download from: https://how2j.cn/k/mybatis/mybatis-tutorial/1087.html#nowhere

Is a great god, please help to see what situation

CodePudding user response:

The Category. The content of the XML

 
<? The XML version="1.0" encoding="utf-8"?>
PUBLIC "-//mybatis.org//DTD Mapper/3.0/EN"
"Http://mybatis.org/dtd/mybatis-3-mapper.dtd" & gt;



CodePudding user response:

The content of the Category. Java

 
Package com. How2java;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

The import org. Apache. Ibatis. IO. Resources;
The import org. Apache. Ibatis. Session. SqlSession;
The import org. Apache. Ibatis. Session. SqlSessionFactory;
The import org. Apache. Ibatis. Session. The SqlSessionFactoryBuilder is;

The import com. How2java. Pojo. The Category;

Public class TestMybatis {

Public static void main (String [] args) throws IOException {
The String resource="mybatis - config. XML";
InputStream inputStream=Resources.getResourceAsStream(resource);
SqlSessionFactory sqlSessionFactory=new SqlSessionFactoryBuilder().build(inputStream);
SqlSession session.=sqlSessionFactory openSession ();

List Cs=session. SelectList (" listCategory ");
For (cs) Category c: {
Be sad etName chtistina georgina rossetti.british poetess System. Out. Println (());
}

}
}

CodePudding user response:

Post the complete error message

CodePudding user response:

refer to the original poster caoyuanlaoshi response:
use Mybatis first connect to the database error: FATAL [main] main - getAssociatedStylesheets failed
The source code download from: https://how2j.cn/k/mybatis/mybatis-tutorial/1087.html#nowhere
Ask god to help look at what's situation,

Use Mybatis first connect to the database error: FATAL [main] main - getAssociatedStylesheets failed

The source code download from: https://how2j.cn/k/mybatis/mybatis-tutorial/1087.html#nowhere

Is a great god, please help to see what is ha



The problem of many links to the mysql database are versions of the problem, because a lot of learning materials are the old version is mysql5.0
You make sure your mysql database version is 5.0, the current version mysql8.0 driver and connection string is not the same,
  • Related