Sometimes you will end up in getting an exception like below when starting a server pointed to MySQL DB.
ERROR - DatabaseUtil Database Error - Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server
One possible reason can be since you have mapped, bind-address to an IP in /etc/mysql/my.cnf
The default is 0.0.0.0 which is all interfaces. This setting does not
restrict which IPs can access the server, unless you specified
127.0.0.1 for localhost only or some other IP.
bind-address = 0.0.0.0
Once this is done, restart mysql server.
sudo service mysql restart
Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts
Tuesday, July 7, 2015
Tuesday, February 17, 2015
One possible reason and solution for getting Access denied for user 'username'@'host' in mysql when accessing from outside
Sometimes we might get the below exception when creating a DB connection.
{org.apache.synapse.mediators.db.DBLookupMediator}
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'username'@'203.94.95.133'
Reasons :
The particular IP might not be accessible from outside.
Therefore you need to grant priviledges by the below command in mysql :
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
Sometimes you might try out below :
GRANT ALL PRIVILEGES ON *.* TO 'password'@'%' WITH GRANT OPTION;
Eventhough it says Query OK, still the issue can be there since you have not used the password.
Also you must do a Flush privileges to update it.
Hope this might help sometimes.
{org.apache.synapse.mediators.db.DBLookupMediator}
org.apache.commons.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Access denied for user 'username'@'203.94.95.133'
Reasons :
The particular IP might not be accessible from outside.
Therefore you need to grant priviledges by the below command in mysql :
GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
Sometimes you might try out below :
GRANT ALL PRIVILEGES ON *.* TO 'password'@'%' WITH GRANT OPTION;
Eventhough it says Query OK, still the issue can be there since you have not used the password.
Also you must do a Flush privileges to update it.
Hope this might help sometimes.
Sunday, June 23, 2013
How to create a MySQL database and a datasource using WSO2 Appfactory
To access : https://appfactorypreview.wso2.com
With the beta release of WSO2 App factory, it enables you to create a
database and datasource for the applications you create using App
Factory.
Current latest version supports MySQL.
This blog post explains you steps to create a database and a
datasource and how to point them in a Web application (WAR) created
using WSO2 App Factory.
For more information on WSO2 App Factory :
To
create a WAR/ Web app supports the datasource
- Registered user can successfully login to WSO2 app factory and create a web application. As an example I will be creating a web application named ColourFindApp.
Application Creation - Once I created the application, I will be assigning user roles for the application using the Team page.
- Then a developer or the app owner which has developer rights will be checking out the source code using GIT and do the necessary code level changes via Developer studio and then commit the code.
http://ushanib.blogspot.com/2013/02/steps-to-checkout-and-commit-wso2.html - As an example assume in my source code, I refer my datasource as colour. So the sample code in my application source code will be something like below.
E.g.,…............
Hashtable hashtable = new Hashtable();
hashtable.put("java.naming.factory.initial","org.wso2.carbon.tomcat.jndi.CarbonJavaURLContextFactory");
Context initContext = new InitialContext(hashtable);
ds = (DataSource) initContext.lookup("jdbc/colour");
Connection conn = ds.getConnection();
Statement statement = conn.createStatement();
…............
- So the datasource I will be creating should be named as colour.
Databases Permission level
User Role | Permission |
---|---|
App Owner | Can create and configure databases in Development, Testing and Staging |
Developer | Can create and configure databases in Development and Testing environments |
QA/Tester | Can create and configure databases in Testing and Staging environments |
Dev-Ops | Can create and configure databases in Staging and Production environments |
- A user can login to the system and select the resource section to create a database.
- User can create the database as per the above permission. Visibility of Database environment will be as above user role permission. User will be able to select the environment from the drop down. DB User and template can be created inline or separately and select it form the drop down.
- Created users and the templates for each environment will be loaded depends on the selected database environment.Datasource Permission Level
User Role | Permission |
---|---|
App Owner | Can create and edit datsources in Development, Testing and Staging |
Developer | Can create and edit datasources in Development and Testing environments |
QA/Tester | Can configure created datasources in Testing and Staging environments |
Dev-Ops | Can configure created datadources in Staging and Production environments |
- App owner can create a datasource and provide the database url created initially. E.g., I create a database named COL_DB and Datasource as colour.
- Then a datasource will be copied in to testing and staging as well along with the provided database URL. E.g., If I provide the database URL of the development stage it will copy the database URL of development stage in testing and staging as well.
E.g., jdbc:mysql://rss.dev.appfactorypreview.wso2.com:3306/COL_DB - If a developer logs in to the system, he or she will see the datasources created in Dveloement and testing stages.
- A Developer or a testing user can create another database in testing environment and select the datasource created and the stage as Testing and provide the newly created database URL of the testing stage. E.g., Database created in testing : COL_DB in testing storage server and select the colour as the datasource and the stage as testing and the testing DB URL and update it.
E.g., jdbc:mysql://rss.test.appfactorypreview.wso2.com:3306/COL_DB - This will enable the different users to easily update their datasource with their desired database location and test the application.
- Depends on the stage selected, existing database URL and attached users will be loaded.
- If not a developer or a tester can test their application with the datasource created initially which points to the database in the development without editing and configuring it to the different environment.
- When promoting the application in to proceeding stage it will refer the database pointed to the promoted environment.
- Only Dev Ops have permission to configure the production environment. Therefore DevOps will have to select the stage as Production and provide the database URL accordingly.
Labels:
app factory,
appfactory,
Configure Resource,
Databases,
Datasources,
MySQL,
Resources,
WSO2
Subscribe to:
Posts (Atom)