开发者

Problem with lunching Java app (Spring, Hibernate) on Debian (MySQL)

</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"/>
     &开发者_StackOverflow中文版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(!!!


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜