hibernate 配置没有错误,建表语句,不能执行
public class ExportUtil {
public static void main(String[] args) {
Configuration c = new Configuration()
.configure("hibernate/cfg/hibernate.cfg.xml");
SchemaExport export = new SchemaExport(c);
export.create(true, true);
}
}
//hibernate.cfg.xml
<session-factory>
<property name="myeclipse.connection.profile">dangdang</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/dangdang?useUnicode=true&characterEncoding=utf8
</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="format_sql">true</property>
<property name="show_sql">true</property>
<mapping resource="hibernate/hbm/User.hbm.xml" />
</session-factory>
</hibernate-configuration>
//User.hbm.xml
<hibernate-mapping>
<class name="com.tarena.entity.User" table="d_d_user">
<id name="id" column="id">
<generator class="native" />
</id>
<property name="email" column="email" />
<property name="nickname" column="nickname" />
<property name="password" column="password" />
<property name="emailVerify" column="is_email_verify" />
<property name="verifyCode" column="email_verify_code" />
<property name="lastLogin" column="last_login_time" type="date"/>
<property name="lastIP" column="last_login_ip" />
</class>
</hibernate-mapping>
//User.java
package com.tarena.entity;
import java.sql.ResultSet;
public class User {
private int id;
private String email;
private String nickname;
private String password;
// email是否已经验证 0-未验证 1-已经验证
private int emailVerify;
// email验证码
private String verifyCode;
private long lastLogin;
private String lastIP;
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public int getEmailVerify() {
return emailVerify;
}
public void setEmailVerify(int emailVerify) {
this.emailVerify = emailVerify;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getLastIP() {
return lastIP;
}
public void setLastIP(String lastIP) {
this.lastIP = lastIP;
}
public long getLastLogin() {
return lastLogin;
}
public void setLastLogin(long lastLogin) {
this.lastLogin = lastLogin;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getVerifyCode() {
return verifyCode;
}
public void setVerifyCode(String verifyCode) {
this.verifyCode = verifyCode;
}
}
--------------------编程问答-------------------- 控制台也不打印东西,这是怎么回事 --------------------编程问答-------------------- jdbc:mysql://localhost:3306
改为jdbc:mysql://127.0.0.1:3306试试
补充:Java , Web 开发