Hibernate connection Database problem Org.apache.commons.dbcp.SQLNestedException:Cannot Create Poolableconnectionfactory

Source: Internet
Author: User

The problem with hibernate cannot connect to the database:

ERROR:HHH000231:Schema Export unsuccessful

(Access denied for user ' root ' @ ' 192.168.1.109 ' (using Password:no)

At Org.apache.commons.dbcp.BasicDataSource.createPoolableConnectionFactory (basicdatasource.java:1549)

At Org.apache.commons.dbcp.BasicDataSource.createDataSource (basicdatasource.java:1388)

Configured as follows

@Beanpublic DataSource DataSource () {Basicdatasource DataSource = new Basicdatasource ();d atasource.seturl ("Jdbc:mysql ://localhost:3306/shopping ");d atasource.setdriverclassname (" Com.mysql.jdbc.Driver ");    Datasource.setusername ("root");    Datasource.setpassword ("");    return dataSource;}

That is to say that hiberate the localhost to 192.168.1.109 is the computer above the Ip,mysql will be considered a remote access, but MySQL is not configured such a host, in fact, MySQL configuration has been configured with localhost and 127.0.0.1 Two ways of matching.

So why does hibernate not parse localhost into 127.0.0.1?

There are many kinds of solutions:

1. Modify Hibernate configuration to

Jdbc:mysql://127.0.0.1:3306/shopping

2. Modify MySQL

Add an 192.168.1.109 IP right

3. How to modify MySQL once, then hibernate using localhost has been able to access MySQL, I think you can build a middle tier, to match the current computer's IP as long as the match, you can log in

Configure the host to Dongfusong.local, as long as the dongfusong.local can dynamically match the computer's IP to be able.

Hibernate connection Database problem Org.apache.commons.dbcp.SQLNestedException:Cannot Create Poolableconnectionfactory

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.