hibernate4.2.2使用schemaExport生成數據表報錯,junit提示:SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using password: NO))


給mysql的root授權遠程連接

 

1 mysql -u root –p
2 mysql>use mysql;
3 mysql>update user set host = '%' where user = 'root';
4 mysql>select host, user from user;

hibernate.cfg.xml的內容

1 <property name="connection.username">root</property>
2 <property name="connection.password">0318</property>

junit的測試內容

1 ServiceRegistry serviceRegistry = new StandardServiceRegistryBuilder().configure().build();
2 
3         MetadataImplementor metadataImplementor = (MetadataImplementor)
4         new MetadataSources(serviceRegistry).buildMetadata();
5 
6         SchemaExport export = new SchemaExport(serviceRegistry, metadataImplementor);
7         export.create(true, true);

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM