</bean id="mySqlDataSource" > class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/mysqljava"/>
&开发者_StackOverflow中文版lt;property name="username" value="mysqljava"/>
<property name="password" value="the_bbt"/>
</bean>
<bean id="mySqlSessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="mySqlDataSource"/>
<property name="mappingResources">
<list>
<value> hibernate/SimpleEntity.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<value>
hibernate.dialect=org.hibernate.dialect.MySQLDialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=create
hibernate.current_session_context_class=thread
</value>
</property>
</bean>
above my Spring config, why my app throws:
[java] 02.12.2010 18:29:13 org.hibernate.cfg.SettingsFactory buildSettings
[java] WARNING: Could not obtain connection to query metadata
[java] java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)
[java] at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1075)
and any problem on Windows(!!!
you need to configure your database access credentials, in the datasource, which is not shown.
If you have configured username/passwords, maybe mysql on your linux install does not even have the database setup?
Are you sure you gave the 'root' user enough rights relative to the host 'localhost'? You can check via MySQL Workbench or any other manager you have available, if you don't like the SQL command line.
Have you granted access for mysqljava user to mysqljava db?
Please run it in your mysql env from root user:
CREATE DATABASE mysqljava;
GRANT ALL PRIVILEGES ON mysqljava.* TO 'mysqljava'@'localhost' IDENTIFIED BY 'the_bbt' WITH GRANT OPTION;
Then connect w/ mysqljava user:
mysql -umysqljava -pthe_bbt
use mysqljava;
SHOW TABLES;
And show me results.
精彩评论