1

</bean id="mySqlDataSource" > class="org.springframework.jdbc.datasource.DriverManagerDataSource">

     &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"/>
     &lt;property name="url" value="jdbc:mysql://127.0.0.1:3306/mysqljava"/>
     &lt;property name="username" value="mysqljava"/>
     &lt;property name="password" value="the_bbt"/>
 &lt;/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(!!!

OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
slavig
  • 339
  • 2
  • 6
  • 19

3 Answers3

0

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?

hvgotcodes
  • 118,147
  • 33
  • 203
  • 236
  • mysql -umysqljava -pthe_bbt mysqljava Reading table information for completion of t..... – slavig Dec 02 '10 at 22:04
  • @slavig, you should XXXX you password out. Does the mysqljava user exist on your debian mysql instance? Does it have the correct permissions? – hvgotcodes Dec 02 '10 at 23:01
0

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.

Eugen
  • 8,523
  • 8
  • 52
  • 74
0

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.

sashko
  • 1