第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

Cannot find class: com.mysql.jdbc.Driver

Cannot find class: com.mysql.jdbc.Driver

qq_莫非 2019-01-24 13:17:40
mybatis-config.xml: <?xml?version="1.0"?encoding="UTF-8"??><!DOCTYPE?configuration????PUBLIC?"-//mybatis.org//DTD?Config?3.0//EN"????"http://mybatis.org/dtd/mybatis-3-config.dtd"><!--通過這個(gè)配置文件,完成mybatis與數(shù)據(jù)庫(kù)的連接??--><configuration>????<!--?注意此配置文件內(nèi)的元素的??-->????<!--?引入database.properties文件?-->????????????????<!--?設(shè)置類的別名?-->????<typeAliases>????????<!--?根據(jù)包取別名,把包下面的所有類都按類名來(lái)取別名?-->????????<typeAlias?type="com.ljh.mybatis.pojo.Student"?alias="u"/>????</typeAliases>????<environments?default="development">????<environment?id="development">??????<transactionManager?type="JDBC"></transactionManager>??????<dataSource?type="UNPOOLED">???????? <property?name="driver"?value="com.mysql.jdbc.Driver"/>???????? <property?name="url"?value="jdbc:mysql://localhost:3306/test1"/>???????? <property?name="username"?value="root"/>???????? <property?name="password"?value="1997520"/>??????</dataSource>????</environment>??</environments>????????????<!--?pojo的映射文件UserMapper引入到配入到配置文件中?-->????<mappers>????????<mapper?class="com.ljh.mybatis.mapper.StudentMapper"/>????</mappers>?</configuration> StudentMapper: package?com.ljh.mybatis.mapper;import?java.util.ArrayList;import?com.ljh.mybatis.pojo.Student;public?interface?StudentMapper?{ public?ArrayList<Student>?getallstudents();} StudentMapper.xml: <?xml?version="1.0"?encoding="UTF-8"?><!DOCTYPE?mapper????PUBLIC?"-//mybatis.org//DTD?Mapper?3.0//EN"????"http://mybatis.org/dtd/mybatis-3-mapper.dtd"><mapper?namespace="com.ljh.mybatis.mapper.StudentMapper"> <select?id="getallstudents"?resultType="u"> select?*?from?student?where?1=1 </select></mapper> Student: package?com.ljh.mybatis.pojo;public?class?Student?{ private?int?id; private?String?stuid; private?String?password; private?String?name; public?int?getId()?{ return?id; } public?void?setId(int?id)?{ this.id?=?id; } public?String?getStuid()?{ return?stuid; } public?void?setStuid(String?stuid)?{ this.stuid?=?stuid; } public?String?getPassword()?{ return?password; } public?void?setPassword(String?password)?{ this.password?=?password; } public?String?getName()?{ return?name; } public?void?setName(String?name)?{ this.name?=?name; } public?Student(int?id,?String?stuid,?String?password,?String?name)?{ super(); this.id?=?id; this.stuid?=?stuid; this.password?=?password; this.name?=?name; } public?Student()?{ } } Test: package?com.ljh.mybatis.test;import?java.io.IOException;import?java.io.Reader;import?java.util.ArrayList;import?org.apache.ibatis.io.Resources;import?org.apache.ibatis.session.SqlSession;import?org.apache.ibatis.session.SqlSessionFactory;import?org.apache.ibatis.session.SqlSessionFactoryBuilder;import?com.ljh.mybatis.mapper.StudentMapper;import?com.ljh.mybatis.pojo.Student;public?class?Test?{ public?static?void?main(String[]?args)?{ try?{ //1、加載配置文件 Reader?reader=Resources.getResourceAsReader("mybatis-config.xml"); //2、得到sessionfactorybuilder SqlSessionFactoryBuilder?sfb=new?SqlSessionFactoryBuilder(); //3、得到sqlsessionfactory SqlSessionFactory?factory=sfb.build(reader); //4、得到sqlsession SqlSession?session=factory.openSession(); //5、得到Mapper映射器 StudentMapper?mapper=session.getMapper(StudentMapper.class); ArrayList<Student>?stu=mapper.getallstudents(); for(int?i=0;i<stu.size();i++){ System.out.println(stu.get(i).getName()); } session.close(); }?catch?(Exception?e)?{ e.printStackTrace(); } }}
查看完整描述

1 回答

已采納
?
sunyaox

TA貢獻(xiàn)68條經(jīng)驗(yàn) 獲得超6個(gè)贊

先檢查一下,項(xiàng)目里是否引入了,mysql的jar包。

查看完整回答
反對(duì) 回復(fù) 2019-01-24
  • 1 回答
  • 0 關(guān)注
  • 3159 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)