标签:
今天在对一个表生成映射文件的时候,都出现“generating artifacts"的问题,查看workspace\.metadata\.log,会发现错误原因:
org.hibernate.exception.GenericJDBCException: Getting database metadata
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:103)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:91)
at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.getMetaData(AbstractMetaDataDialect.java:64)
at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.caseForSearch(AbstractMetaDataDialect.java:163)
at org.hibernate.cfg.reveng.dialect.JDBCMetaDataDialect.getTables(JDBCMetaDataDialect.java:22)
at org.hibernate.cfg.reveng.JDBCReader.processTables(JDBCReader.java:476)
at org.hibernate.cfg.reveng.JDBCReader.readDatabaseSchema(JDBCReader.java:74)
at com.genuitec.eclipse.hibernate.wizards.MEJDBCMetaDataConfiguration$1.readDatabaseSchema(MEJDBCMetaDataConfiguration.java:104)
at org.hibernate.cfg.JDBCBinder.readFromDatabase(JDBCBinder.java:89)
at com.genuitec.eclipse.hibernate.wizards.MEJDBCMetaDataConfiguration.readFromJDBC(MEJDBCMetaDataConfiguration.java:137)
at com.genuitec.eclipse.hibernate.wizards.GenerateArtifactsJob$7.execute(GenerateArtifactsJob.java:877)
at org.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:65)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:91)
at com.genuitec.eclipse.hibernate.wizards.GenerateArtifactsJob.buildConfiguration(GenerateArtifactsJob.java:858)
at com.genuitec.eclipse.hibernate.wizards.GenerateArtifactsJob.run(GenerateArtifactsJob.java:405)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
Caused by: java.sql.SQLException: Access denied for user ‘root‘@‘localhost‘ (using
password: YES)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:919)
at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1694)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1244)
at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2412)
at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2445)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2230)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:813)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:395)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:334)
at org.hibernate.console.FakeDelegatingDriver.connect(FakeDelegatingDriver.java:40)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:110)
at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.getConnection(AbstractMetaDataDialect.java:122)
at org.hibernate.cfg.reveng.dialect.AbstractMetaDataDialect.getMetaData(AbstractMetaDataDialect.java:61)
... 13 more
解决方案:
关闭MyEclipse,重新启动一下,然后再做一次数据库表的映射就没问题了。
-----------------------------------------------------------------------------------------------------
在myeclipse中使用hibernate进行“Hibernate Reverse Engineering”报如下错:
!ENTRY org.eclipse.core.jobs 4 2 2010-12-27 14:20:11.625
!MESSAGE An internal error occurred during: "Generating Artifacts".
!STACK 0
java.lang.IllegalArgumentException: Path must include project and resource
name: /at org.eclipse.core.runtime.Assert.isLegal(Assert.java:62) at
org.eclipse.core.internal.resources.Workspace.newResource(Workspace.java:1631)
at org.eclipse.core.internal.resources.Container.getFile(Container.java:123)
atcom.genuitec.eclipse.hibernate.util.HibernateUtils.getConfigFile(HibernateUtils.java:510)
atcom.genuitec.eclipse.hibernate.util.HTUtils.getConsoleConfigurationPreferences(HTUtils.java:184)
atcom.genuitec.eclipse.hibernate.util.HTUtils.getConsoleConfiguration(HTUtils.java:175)
atcom.genuitec.eclipse.hibernate.util.HTUtils.getConsoleConfiguration(HTUtils.java:165)
atcom.genuitec.eclipse.hibernate.wizards.GenerateArtifactsJob.run(GenerateArtifactsJob.java:361)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)
解决方案:
修改.myhibernatedata(工程下)文件里面的configFile属性
指定applicationContext.xml路径。格式是/项目名称/路径/applicationContext.xml
.myhibernatedata文件
##Sat Sep 19 15:30:33 CST 2009
genBasicCompId=true
sessionFactoryName=liss.samples.myssh2.domain.HibernateSessionFactory
profile=
daoSFId=
version=3.3
jndiPath=
springDaoFile=
useJavaTypes=true
keyGenerator=increment
libInstallFolder=
addLibs2Project=false
genVersionTag=true
sessionFactoryId=
basePersistenceClass=
reSettingsFile=/myssh2/hibernate.reveng.xml
configFile=/myssh2/conf/applicationContext.xml
createConfigFile=false
addLibs2Classpath=false
baseDaoClass=BaseHibernateDAO
对一个表生成映射文件的时候,都出现“generating artifacts"的问题,查看workspace\.metadata\.log,会发现错误原因:
org.hibernate.HibernateException:
Dialect class not found: at
org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:81)
at org.hibernate.dialect.DialectFactory.buildDialect(DialectFactory.java:42)
at org.hibernate.cfg.SettingsFactory.determineDialect(SettingsFactory.java:409)
at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:119)
at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1929)
atcom.genuitec.eclipse.hibernate.wizards.MEJDBCMetaDataConfiguration.readFromJDBC(MEJDBCMetaDataConfiguration.java:73)
atcom.genuitec.eclipse.hibernate.wizards.GenerateArtifactsJob$9.execute(GenerateArtifactsJob.java:819)
atorg.hibernate.console.execution.DefaultExecutionContext.execute(DefaultExecutionContext.java:56)
at org.hibernate.console.ConsoleConfiguration.execute(ConsoleConfiguration.java:89)
atcom.genuitec.eclipse.hibernate.wizards.GenerateArtifactsJob.buildConfiguration(GenerateArtifactsJob.java:803)
atcom.genuitec.eclipse.hibernate.wizards.GenerateArtifactsJob.run(GenerateArtifactsJob.java:381)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:58)
解决方案:回头一看配置文件,<property name="hibernate.dialect"></property>中间没东西,呵呵,加入org.hibernate.dialect.Oracle9Dialect再试,就可以了。
仔细检查了hibernate的各项配置,按说并无不妥;
<?xml version=‘1.0‘ encoding=‘UTF-8‘?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.username">hibernate</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:oracle</property>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="connection.password">hibernate</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="myeclipse.connection.profile">
OracleDriver
</property>
<mapping resource="com/thomas/events/Event.hbm.xml" />
</session-factory>
</hibernate-configuration>
解决方案:把localhost该为ip的形式,就好使了;另外注意,在*.hbm.xml配置中,如果使用date类型的话,存入到数据库的日期是没有时分秒的时间,如果要保存整个事件的话要使用timestamp类型
标签:
原文地址:http://blog.csdn.net/szms1/article/details/44133593