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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

大神幫忙?。?!找不到students表,ERROR: Table 'hibernate.students' doesn't exist

hibernate.cfg.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
?? ??? ?"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
?? ??? ?"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
??? <session-factory>
?? ??? ?<property name="connection.username">root</property>
?? ??? ?<property name="connection.password">root</property>
?? ??? ?<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
?? ??? ?<property name="connection.url">jdbc:mysql:///hibernate?userUnicode=true&amp;characterEncoding=UTF-8</property>? ??? ?
?? ??? ?<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
?? ??? ?<property name="show_sql">true</property>
?? ??? ?<property name="format_sql">true</property>? ??? ?
?? ??? ?<property name="hbm2ddl.auto">create</property>
?? ??? ?<mapping resource="Students.hbm.xml"/>
??? </session-factory>
</hibernate-configuration>


Students.hbm.xml:

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2016-4-3 15:32:14 by Hibernate Tools 3.5.0.Final -->
<hibernate-mapping>
??? <class name="Students" table="STUDENTS">
??????? <id name="sid" type="int">
??????????? <column name="SID" />
??????????? <generator class="assigned" />
??????? </id>
??????? <property name="sname" type="java.lang.String">
??????????? <column name="SNAME" />
??????? </property>
??????? <property name="gender" type="java.lang.String">
??????????? <column name="GENDER" />
??????? </property>
??????? <property name="birthday" type="java.util.Date">
??????????? <column name="BIRTHDAY" />
??????? </property>
??????? <property name="address" type="java.lang.String">
??????????? <column name="ADDRESS" />
??????? </property>
??? </class>
</hibernate-mapping>


Students.java


import java.util.Date;

//學(xué)生類
public class Students {
?? ?// 1.共有的類
?? ?// 2.提供共有的不帶參數(shù)的默認(rèn)的構(gòu)造方法
?? ?// 3.屬性私有
?? ?// 4.屬性getter/setter方法

?? ?private int sid;
?? ?private String sname;
?? ?private String gender;
?? ?private Date birthday;
?? ?private String address;

?? ?public Students() {

?? ?}

?? ?public Students(int sid, String sname, String gender, Date birthday, String address) {
//?? ??? ?super();
?? ??? ?this.sid = sid;
?? ??? ?this.sname = sname;
?? ??? ?this.gender = gender;
?? ??? ?this.birthday = birthday;
?? ??? ?this.address = address;
?? ?}

?? ?public int getSid() {
?? ??? ?return sid;
?? ?}

?? ?public void setSid(int sid) {
?? ??? ?this.sid = sid;
?? ?}

?? ?public String getSname() {
?? ??? ?return sname;
?? ?}

?? ?public void setSname(String sname) {
?? ??? ?this.sname = sname;
?? ?}

?? ?public String getGender() {
?? ??? ?return gender;
?? ?}

?? ?public void setGender(String gender) {
?? ??? ?this.gender = gender;
?? ?}

?? ?public Date getBirthday() {
?? ??? ?return birthday;
?? ?}

?? ?public void setBirthday(Date birthday) {
?? ??? ?this.birthday = birthday;
?? ?}

?? ?public String getAddress() {
?? ??? ?return address;
?? ?}

?? ?public void setAddress(String address) {
?? ??? ?this.address = address;
?? ?}

?? ?@Override
?? ?public String toString() {
?? ??? ?return "Students [sid=" + sid + ", sname=" + sname + ", gender=" + gender + ", birthday=" + birthday
?? ??? ??? ??? ?+ ", address=" + address + "]";
?? ?}
?? ?
?? ?
}


StudentsTest.java

import java.util.Date;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

public class StudentsTest {
?? ?
?? ?private SessionFactory sessionFactory;
?? ?private Session session;
?? ?private Transaction transaction;

?? ?@Before
?? ?public void init(){
?? ??? ?//創(chuàng)建配置對(duì)象
?? ??? ?Configuration config=new Configuration().configure();
?? ??? ?//創(chuàng)建服務(wù)注冊(cè)對(duì)象
?? ??? ?ServiceRegistry serviceRegistry=new ServiceRegistryBuilder().applySettings(config.getProperties()).buildServiceRegistry();
?? ??? ?//創(chuàng)建會(huì)話工廠對(duì)象
?? ??? ?sessionFactory=config.buildSessionFactory(serviceRegistry);
?? ??? ?//會(huì)話對(duì)象
?? ??? ?session=sessionFactory.openSession();
?? ??? ?//開啟事物
?? ??? ?transaction=session.beginTransaction();
?? ??? ?
?? ?}
?? ?
?? ?@After
?? ?public void destory(){
?? ??? ?transaction.commit();
?? ??? ?session.close();
?? ??? ?sessionFactory.close();
?? ??? ?
?? ?}
?? ?
?? ?@Test
?? ?public void testSaveStudents(){
?? ??? ?Students s=new Students(1,"張三豐","男",new Date(),"武當(dāng)山");
?? ??? ?session.save(s);
?? ?}
}


正在回答

3 回答

你是自動(dòng)生成的hbm.xml嗎

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

沉寂的蝸牛 提問者

是的,可能是什么問題,會(huì)不會(huì)是Hibernatetools安裝出問題了?
2016-04-06 回復(fù) 有任何疑惑可以回復(fù)我~
#2

沉寂的蝸牛 提問者

謝謝啦。。。是eclipse抽風(fēng)了吧,隔了兩天試試又有用了
2016-04-06 回復(fù) 有任何疑惑可以回復(fù)我~

<mapping resource="Students.hbm.xml"/>

你如果沒把Students.hbm.xml放在src下就必須要加上他的跟路徑eg:

<mapping ?resource="com/entity/Student.hbm.xml"/>

我的就是放在com.entity的,找不到是因?yàn)槟阌成渎窂綄?duì)不上!

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

沉寂的蝸牛 提問者

哦,謝謝。
2016-04-08 回復(fù) 有任何疑惑可以回復(fù)我~

是的,可能是什么問題,會(huì)不會(huì)是Hibernatetools安裝出問題了?

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

大神幫忙!??!找不到students表,ERROR: Table 'hibernate.students' doesn't exist

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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